iconv (conversion between different Charset e.g.UTF8->Big
Posted: Fri Jun 06, 2003 12:02 pm
I have asked not too long ago about conversions between Big5 to UTF8. I got the answer. You need to have iconv php support in Apache server and the iconv libiconv installed.
Here is the code I come up:
I believe the code can used to exchange same language with different encoding (e.g. Big5 <-> BG, ECU <-> Shift JIS). I never try. Correct me if wrong.
I have problems regarding this code. When a file is long, output text in text file will be truncated either in the beginning or at the end. However, the displayed text will be okay. I am confused.
What is the problem with this one?
Thanks
Here is the code I come up:
Code: Select all
<?php
$file = fopen("utf8text.txt","r");
while (!feof($file))
{
$content = fgets($file, 1000000);
$out = iconv ("utf-8","big5", $content);
echo $out;
}
fclose($file);
$ofile = fopen ("out.txt", "w+");
fwrite ($ofile, $out);
fclose($ofile);
?>I have problems regarding this code. When a file is long, output text in text file will be truncated either in the beginning or at the end. However, the displayed text will be okay. I am confused.
What is the problem with this one?
Code: Select all
$ofile = fopen ("out.txt", "w+");
fwrite ($ofile, $out);
fclose($ofile);