#48891 [Com]: command line output problem

From: Date: Sun, 12 Jul 2009 07:42:17 +0000
Subject: #48891 [Com]: command line output problem
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-139635@lists.php.net to get a copy of this message
ID: 48891 Comment by: sjoerd-php at linuxonly dot nl Reported By: hunt_inet at yahoo dot com Status: Open Bug Type: Output Control Operating System: WinXP sp3 (Chinese traditional) PHP Version: 5.2.10 New Comment: Thank you for your bug report. The character encoding specifies how bytes are converted to letters. This is important if you want to output non-ASCII letters. When outputting to the browser, any character encoding can be used as long as you tell the browser which one you are using. You can not expect non-ASCII letters to work in the browser unless you inform the browser which character encoding you are using, with a HTTP header or <?xml tag. With the console, you would have to output something in the character encoding of the console. I do not think this is a bug in PHP. Previous Comments: ------------------------------------------------------------------------ [2009-07-12 03:24:21] hunt_inet at yahoo dot com Description: ------------ I faced some problem to correctly output text from php command line file. So I wrote a samll test and save it as "hello.php" as the code listed below. If I saved it in UTF-8 format and executed it in the command line, then it output some garbage (chinese part) and part of correct text (English part). But if I ran it in browser, the output is correct. Also, if I save it in ANSI format (I believe it is in multi-byte format) then the output is correct in command line. But its output is some garbage (chinese part) in browser view. I guess this is a bug. Hunt Chang Reproduce code: --------------- <?php // cause this file is saved in UTF-8 format setlocale(LC_ALL, 'zh_TW.UTF8'); // warning: not 'UTF-8'! // setlocale(LC_ALL, 'zh_TW'); // warning: not 'UTF-8'! // You may execute this script by typing: // php hello_cmd.php print "Hello world!\n"; echo "Hello world!\n"; echo '歡迎光臨!' . "\n"; echo "歡迎光臨!\n"; ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48891&edit=1

« previous php.bugs (#139635) next »