|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-12-27 18:24 UTC] yury at gorodok dot net
Description: ------------ The code must translate UTF-8 to windows-1251, but it truncates output! May be old compiled in version of libiconv? examples follow: UTF-8: http://yury.gorodok.net/temp/test_.html result: http://yury.gorodok.net/temp/test_1.html (the content is not essential, I suppose) Reproduce code: --------------- $fstr=fread($f, $flen); $ffstr=iconv( "windows-1251", "UTF-8",$fstr); echo fwrite($ff,$ffstr, strlen($ffstr))."\n"; PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
Just not using third parameter in fwrite() _doesn't_help_ a bit! All lines with mbstring were (and are) commented out; I cann't see it in my phpinfo()-- so, I cann't say what value mbstring.func_overload has. Here is the code, that doesn't work now: $f=fopen($fns, "rb"); $ff=fopen($fnts, "wb"); $flen=filesize($fns); $fstr=fread($f, $flen); echo $flen."\n"; $ffstr=iconv("UTF-8","windows-1251",$fstr); echo strlen($ffstr)."\n"; echo fwrite($ff,$ffstr/*,strlen($ffstr)*/)."\n"; fclose($ff); fclose($f); Also, for some other files (that translated good), there was no problem with length.Here is the full script: (the files on which I've experienced the bug, I've pointed earlier) <?php // UTF->WIN if ( count($argv)< 2) { echo "\n2 arguments needed!\n"; exit; } $fns=$argv[1]; $fnts=$argv[2]; $f=fopen($fns, "rb"); $ff=fopen($fnts, "wb"); $flen=filesize($fns); $fstr=fread($f, $flen); echo $flen."\n"; $ffstr=iconv("UTF-8","windows-1251",$fstr); echo strlen($ffstr)."\n"; echo fwrite($ff,$ffstr/*,strlen($ffstr)*/)."\n"; fclose($ff); fclose($f); ?>