채택완료

curl 엔코딩속성

2015-06-30 (화) 13:24:16 2,646

아래와 같이 하면.. 생성된 파일엔코딩속성이 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 포인트

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

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 를

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

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