Converting CSV file to UCS-2LE encoding with php -


i'm creating csv file. need in ucs-2le encoding. tried following, neither of work:

  • $value = mb_convert_encoding($value,"ucs-2le");
  • $value= iconv( mb_detect_encoding( $value ), 'ucs-2le', $value );

opening file in notepad++ shows encoding ansi.

code:

$file = fopen($filename,"w"); array_walk($csv_data, 'encodecsv');  foreach ($csv_data $line) {     fputcsv($file, explode(',', $line)); }  fclose($file);  function encodecsv(&$value, $key){     $value = mb_convert_encoding($value,"ucs-2le");     //$value= iconv( mb_detect_encoding( $value ), 'ucs-2le', $value ); } 

you should add byte-order-mark (bom) @ beginning of file. should '\xff\xfe' in case:

$file = fopen($filename,"w"); fwrite($file, '\xff\xfe'); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -