|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-04-19 17:56 UTC] vmiszczak at ankama dot com
Description: ------------ Those functions (at least) do strange things when using an UTF-8 terminal under Windows. For instance, doing a php 'echo' on a UTF-8 string does not output the string! Printing the same string with fwrite(STDOUT,$string) works. More problematic : parsing UTF-8 data and trying to execute a program (I've tried popen,exec,proc_open,passthru) with those data as program arguments make the program to not understand the decoding that should be used. Writing the script output to a batch file and executing the batch works. Test script: --------------- Launch a cmd.exe. Execute chcp 65001 to get the terminal use UTF-8 (make sure your font support this, use Lucida console for instance). Launch this script : <?php $data="ï"; fwrite(STDOUT,$data."\n"); echo $data."\n"; ?> Expected result: ---------------- I'm expecting UTF-8 data to be shown correctly and program execution string passed to exec() and so use correct string decoding. Actual result: -------------- ï �� PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
"Windows has no idea about UTF-8" Are you serious?!! C function WideCharToMultiByte(CP_UTF8,NULL,native,- 1,encoded,sizeof(encoded),NULL,NULL) does encode as UTF-8. printf("%s",encoded) does output correct things within a rightly configured terminal, just like you do under Linux. PHP does not.