|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-09-15 12:42 UTC] seven at nivas dot hr
Description:
------------
I am unaware if this is a bug or feature, but it’s strange. It should be fixed or documented somewhere.
I’ve run into this in process of debugging a problem I was having with old code running on php 5.4 and php 5.4.7 which caused all utf8 form data to be submitted in wrong encoding. Instead of “[šđčćž]“ I would get “[Å¡ÄÄÄž]“. After a while I've found out that because of the utf8 changes implemented into php 5.4.x mbstring.http_input=auto should be set to “pass”.
my php.ini has default_charset = "UTF-8" and my form is on utf8 html page and <form tag has accept-charset="utf-8".
Imagine having this in .htaccess file:
php_value mbstring.encoding_translation 1
php_value mbstring.internal_encoding UTF-8
php_value mbstring.http_input auto
and this in php:
echo $_POST['test']; // outputs [Å¡ÄÄÄž]
php ini_get sees this, so all settings are applied ok:
mbstring.internal_encoding:UTF-8
mbstring.encoding_translation:1
mbstring.http_input:auto
The utf8 form data problem occurs.
Now, imagine having only this in .htaccess (since encoding_translation is PHP_INI_PERDIR setting and can’t be set from runtime):
php_value mbstring.encoding_translation 1
and this in php:
mb_internal_encoding ('UTF-8');
mb_http_input('auto');
echo $_POST['test']; // outputs [šđčćž]
php ini_get sees this, so all settings are applied ok:
mbstring.internal_encoding:UTF-8
mbstring.encoding_translation:1
mbstring.http_input:auto
No utf8 data form submission problem.
mbstring.internal_encoding is PHP_INI_ALL setting, however, it does not behave the same if set from .htaccess or .php. It seems to me that setting it from .php does not make any change in how mbstring.http_input will process form data.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 22:00:01 2025 UTC |
I tested with the new Firefox and Chrome PHP 5.4.18 - Problem PHP 5.3.3 and 5.2.14 is OK var_dump(mb_detect_order()); // array(2) { [0]=> string(5) "ASCII" [1]=> string(5) "UTF-8" }