테스트 사이트 - 개발 중인 베타 버전입니다

curl 엔코딩속성 채택완료

주니1 10년 전 조회 2,458

아래와 같이 하면.. 생성된 파일엔코딩속성이 euc_kr로 자꾸 저장입니다.

이유가 멀까요? 그리고 어떻게 해야 정상적으로..UTF-8로 저장될까요?

 

<?php

$header = "Content-type: application/x-www-form-urlencoded;charset=UTF-8";

$ch = curl_init("xxx.schedule_fuel.php");

 

$fp = fopen("schedule.csv", "w");

 

curl_setopt($ch, CURLOPT_FILE, $fp);

curl_setopt($ch, CURLOPT_HEADER,  $header);

curl_setopt($ch, CURLOPT_ENCODING , "UTF-8");

curl_exec($ch);

curl_close($ch);

fclose($fp);

 

 echo("complete");  

?>

 

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
편리
10년 전

http://php.net/manual/kr/function.curl-setopt.php">http://php.net/manual/kr/function.curl-setopt.php 내용 중 CURLOPT_ENCODING 은 

 

http://static.se2.naver.com/static/img/bg_quote2.gif) 0 3px no-repeat;color:#888888;">

The contents of the "Accept-Encoding: " header. This enables decoding of the response. Supported encodings are "identity", "deflate", and "gzip". If an empty string, "", is set, a header containing all supported encoding types is sent. 

라고 명시되어 있습니다. UTF-8 등의 문자셋을 지정하는 부분이 아닙니다.

 

파일을 UTF-8로 저장하는 것은 http://stackoverflow.com/questions/10761411/php-curl-utf-8-charset">http://stackoverflow.com/questions/10761411/php-curl-utf-8-charset

참고하셔서 코드를 테스트해보시기 바랍니다.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인