Skip to content

Instantly share code, notes, and snippets.

@virusvn
Forked from br-nhan/convert_usable_format.php
Created January 8, 2015 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virusvn/5de5e0942d2aa9b191bb to your computer and use it in GitHub Desktop.
Save virusvn/5de5e0942d2aa9b191bb to your computer and use it in GitHub Desktop.
<?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