|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78307 Strange caracter in $_POST with mbstring.encoding_translation = On
Submitted: 2019-07-17 15:16 UTC Modified: 2019-07-18 00:46 UTC
From: heidy dot hery at gmail dot com Assigned:
Status: Not a bug Package: mbstring related
PHP Version: 7.3.7 OS: Windows 10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: heidy dot hery at gmail dot com
New email:
PHP Version: OS:


 [2019-07-17 15:16 UTC] heidy dot hery at gmail dot com
Description : 

When I use multipart/form-data for posting data to the php side. 
The $_POST variable output strange caracter like "réveiller". in place of "réveiller".

But I've tested two sites. with the same Apache/PHP configuration... and on the first site, multipart/form-data work correctly, but not on the second site... it's a very strange and non stable behaviour.

the php.ini configuration was as follow :

mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.encoding_translation = On

I've made a test with enctype="application/x-www-form-urlencoded" and the data showed correctly in the $_POST array.

So in order to have the correct behaviour with enctype="multipart/form-data", I've to set the following value in php.ini

mbstring.internal_encoding = UTF-8
mbstring.http_input = UTF-8
mbstring.encoding_translation = Off

Now all is working correctly.

my php version is 7.3.5
apache 2.4.39
Windows 10 x64.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-07-17 16:17 UTC]
-Status: Open +Status: Feedback -Package: *Unicode Issues +Package: mbstring related
 [2019-07-17 16:17 UTC]
What's the value of your default_charset setting? Are your pages being served in UTF-8 encoding or something else?
 [2019-07-17 18:55 UTC] heidy dot hery at gmail dot com
-Status: Feedback +Status: Open
 [2019-07-17 18:55 UTC] heidy dot hery at gmail dot com

my default parameters in php.ini is :

; PHP's built-in default media type is set to text/html.
default_mimetype = "text/html"

; PHP's default character set is set to UTF-8.
default_charset = "UTF-8"

; PHP internal character encoding is set to empty.
; If empty, default_charset is used.
;internal_encoding =

; PHP input character encoding is set to empty.
; If empty, default_charset is used.
;input_encoding =

; PHP output character encoding is set to empty.
; If empty, default_charset is used.
; See also output_buffer.
;output_encoding =


I use in all my html/php file the header :

<meta charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

in my httpd.conf

I add the line :

AddDefaultCharset utf-8

But that's doesn't change anything, I've put also accept-charset="utf-8" in the form attribute.

The only thing that's worked it's when I've put the "http_input" to UTF-8 and turn off the "encoding_translation".
 [2019-07-18 00:44 UTC]
-Status: Open +Status: Not a bug
 [2019-07-18 00:44 UTC]
In general, you shouldn't use automatic encoding translation because current HTML specification explicitly states client(browser) must send specified char encoding.

In addition, automatic encoding detection requires long and unique enough char data for correct detection. Your input should be short and/or not unique.

Set mbstring.http_input = UTF-8 or none.
 [2019-07-18 00:46 UTC]
Don't forget to set default_charset=UTF-8. This is the setting where you should set char encoding. <meta> may be used, but it's not recommended.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 21 09:01:29 2024 UTC