Skip to content

Instantly share code, notes, and snippets.

@br-nhan
Created January 8, 2015 04:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save br-nhan/6532dfc02cd06d7a5d11 to your computer and use it in GitHub Desktop.
Save br-nhan/6532dfc02cd06d7a5d11 to your computer and use it in GitHub Desktop.
Convert Japanese CSV [Win | Mac]
<?php
public function convert_usable_format($file){
$buf = mb_convert_encoding(file_get_contents($file), "UTF-8", "SJIS-WIN");
$buf = str_replace(array("\r\n", "\n", "\r"), "m9(^v^)", $buf);
$buf = str_replace("m9(^v^)", "\r\n", $buf);
$handle = tmpfile();
fwrite($handle, $buf);
rewind($handle);
return $handle;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment