Bug #54569 [Bgs]: echo,proc_open,... issues with UTF-8 terminal
| From: | pajoye@php.net | Date: | Tue, 19 Apr 2011 16:41:59 +0000 |
| Subject: | Bug #54569 [Bgs]: echo,proc_open,... issues with UTF-8 terminal | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-160288@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54569&edit=1
ID: 54569
Updated by: pajoye@php.net
Reported by: vmiszczak at ankama dot com
Summary: echo,proc_open,... issues with UTF-8 terminal
Status: Bogus
Type: Bug
Package: *General Issues
Operating System: Windows
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
The operating system runtime has no idea about UFT-8, in its shell, its
file name
encoding, etc.
Its internal APIs obviously provide UTF-8 conversion function (or
other).
Secondly, as I said earlier you have to do the conversion manually as
PHP does not
use the WildChar APIs.
Previous Comments:
------------------------------------------------------------------------
[2011-04-19 18:32:26] vmiszczak at ankama dot com
"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.
------------------------------------------------------------------------
[2011-04-19 18:10:50] pajoye@php.net
Windows has no idea about UTF-8, especially not in console mode. But
that does not
mean the data you are echo'ing is not correct UTF-8.
------------------------------------------------------------------------
[2011-04-19 17:56:04] 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:
--------------
ï
��
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54569&edit=1