php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48891 command line output problem
Submitted: 2009-07-12 03:24 UTC Modified: 2009-07-12 12:31 UTC
From: hunt_inet at yahoo dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.2.10 OS: WinXP sp3 (Chinese traditional)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 + 48 = ?
Subscribe to this entry?

 
 [2009-07-12 03:24 UTC] 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";
?>




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-12 07:42 UTC] sjoerd-php at linuxonly dot nl
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.
 [2009-07-12 12:31 UTC] jani@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC