Edit report at https://bugs.php.net/bug.php?id=62351&edit=1
ID: 62351
Comment by: wynn dot chen dot cn at gmail dot com
Reported by: php at sebastianmendel dot de
Summary: UTF-8 chars fail to be printed out properly with
zend.multibyte
Status: Open
Type: Bug
Package: Unicode Engine related
Operating System: GNU/Linux
PHP Version: 5.4.4
Block user comment: N
Private report: N
New Comment:
it's NOT a bug.
after turn on zend.multibyte, just need to enable mbstring extension, and in
php.ini, set:
mbstring.internal_encoding = utf-8
now everything works fine.
test in php-5.4.10, windows2k8.
i guess that php convert php-script from declared encoding to mbstring
internal_encoding first, and then try to execute the script. and default
internal_encoding is something like ASCII, so this problem appears.
Previous Comments:
------------------------------------------------------------------------
[2013-02-11 16:23:14] alexander dot stehlik at gmail dot com
I'm not sure if this issue is related but here is the problem I have with
declare(ENCODING = 'utf-8'):
Tested PHP Versions:
PHP 5.4.6-1ubuntu1.1 (cli)
PHP 5.4.6-1ubuntu1.1 (cgi-fcgi)
Put this in a file (test.php):
<?php
declare(ENCODING = 'utf-8') ;
//ä ü ö
?>
Run php test.php > test.txt
In text.txt you can find some unreadable characters.
This always occurs if there are special chars in any COMMENTS in the PHP file.
------------------------------------------------------------------------
[2012-12-05 09:46:06] bukin242 at yandex dot ru
Please fix in the new versions of php
------------------------------------------------------------------------
[2012-06-18 15:18:20] php at sebastianmendel dot de
Description:
------------
Enabling zend.multibyte and having declare(encoding = UTF-8) in UTF-8 encoded
scripts does not print UTF-8 chars properly.
Same script (still encoded as UTF-8) but with declare(encoding = ISO-8859-1)
prints out UTF-8 chars correct.
>/opt/phpfarm/inst/bin/php-5.4.4 -i | grep multi
zend.multibyte => On => On
>/opt/phpfarm/inst/bin/php-5.4.4 -i | grep UTF
default_charset => UTF-8 => UTF-8
zend.script_encoding => UTF-8 => UTF-8
exif.encode_unicode => UTF-8 => UTF-8
iconv.input_encoding => UTF-8 => UTF-8
iconv.internal_encoding => UTF-8 => UTF-8
iconv.output_encoding => UTF-8 => UTF-8
LANG => de_DE.UTF-8
_SERVER["LANG"] => de_DE.UTF-8
Test script:
---------------
<?php
declare(encoding = 'UTF-8');
echo htmlspecialchars('"aäaÃ', ENT_QUOTES | ENT_IGNORE, 'UTF-8');
echo "\n" . '"aäaÃ';
?>
Expected result:
----------------
"aäaÃ
"aäaÃ
Actual result:
--------------
"aa
"aâaâ
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62351&edit=1