#38577 [Fbk->Opn]: Changing internal character encoding affects function overloading
| From: | php at diptyque dot net | Date: | Thu, 24 Aug 2006 15:04:04 +0000 |
| Subject: | #38577 [Fbk->Opn]: Changing internal character encoding affects function overloading | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101282@lists.php.net to get a copy of this message | ||
ID: 38577
User updated by: php at diptyque dot net
Reported By: php at diptyque dot net
-Status: Feedback
+Status: Open
Bug Type: mbstring related
Operating System: FreeBSD 4.4
PHP Version: 4.4.4
New Comment:
I moved mbstring function overload initial setting (6) from
my php.ini to specific virtual hosts configuration sections
but to no avail.
It would seem that some Apache processes get it right while
others get it wrong (!) This is quite weird -- for example,
process #58902 returns int(18) while #58914 returns
int(19).
[diptyque] % GET http://localhost/bugs/mbinfo2.php
<pre>int(58902)
string(10) "ISO-8859-1"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
int(19)
--
bool(true)
string(5) "UTF-8"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
int(18)
--
bool(true)
string(10) "ISO-8859-1"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
int(19)
</pre>
[diptyque] % GET http://localhost/bugs/mbinfo2.php
<pre>int(58914)
string(10) "ISO-8859-1"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
int(19)
--
bool(true)
string(5) "UTF-8"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
int(19)
--
bool(true)
string(10) "ISO-8859-1"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
int(19)
</pre>
Previous Comments:
------------------------------------------------------------------------
[2006-08-24 12:41:06] tony2001@php.net
Right, int(19) is what I get on Linux and FreeBSD 5.4.
------------------------------------------------------------------------
[2006-08-24 12:33:17] php at diptyque dot net
Oops, my mistake. You should swap Expected and Actual
results. Actual result is int(18) !? Expected result is
int(19).
------------------------------------------------------------------------
[2006-08-24 12:28:30] php at diptyque dot net
Granted I could not reproduce either this bug using a WAMP
setup but did you follow the hyperlink I gave on my
FreeBSD-based server, where you can consistently replicate
this bug on each GET request?
------------------------------------------------------------------------
[2006-08-24 11:03:09] tony2001@php.net
Can't reproduce. I get int(19) in all cases.
------------------------------------------------------------------------
[2006-08-24 10:17:16] php at diptyque dot net
Description:
------------
Changing internal character encoding during script
execution apparently affects mbstring function overloading:
strlen() returns the length of the string based on current
internal encoding although function overloading is disabled
(either through php.ini, vhost and/or .htaccess settings.)
On apache 1.3 startup or graceful restart, script may run
as expected but repeated requests would inevitably trigger
the bug -- on my server setup, MediaWiki cannot run
reliably because of this weird behavior :-/
The bug is not triggered when I do run this script under
other SAPIs such as CLI or FastCGI.
./configure --with-apxs=/usr/local/apache/bin/apxs
--with-mysql=/usr/local --with-openssl=/usr/local/apache
--with-gd=/usr/local --with-zlib --with-bz2 --with-xml
--with-freetype-dir=/usr/local --with-ttf --with-imap
--with-curl
--with-jpeg-dir=/usr/local --with-png-dir=/usr/local
--with-readline=/usr/local --prefix=/usr/local/apache
--with-config-file-path=/usr/local/apache/etc
--enable-mbstring
--enable-mbregex --enable-zend-multibyte
; configure line
Reproduce code:
---------------
http://www.diptyque.net/bugs/mbinfo.php
; running PHP 4.4 as an apache module
; display charset is set to UTF-8
; when internal encoding is set to UTF-8,
; strlen() returns the wrong character count
; (e.g. 18 instead of 19)
http://www.diptyque.net/bugs/mbinfo.phps
; source code
Expected result:
----------------
string(10) "ISO-8859-1"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
int(19)
--
bool(true)
string(5) "UTF-8"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
int(18)
--
bool(true)
string(10) "ISO-8859-1"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
Actual result:
--------------
string(10) "ISO-8859-1"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
int(19)
--
bool(true)
string(5) "UTF-8"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
int(19)
--
bool(true)
string(10) "ISO-8859-1"
string(10) "ISO-8859-1"
string(1) "0"
string(19) "Méthodes de codage"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38577&edit=1