php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65110 mb_convert_encoding's auto is not work, when using mbstring.language=English
Submitted: 2013-06-24 12:44 UTC Modified: 2017-07-28 19:56 UTC
Votes:8
Avg. Score:4.4 ± 0.9
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:1 (16.7%)
From: f133715 at rmqkr dot net Assigned:
Status: Open Package: mbstring related
PHP Version: 5.4.16 OS: Windows
Private report: No CVE-ID: None
 [2013-06-24 12:44 UTC] f133715 at rmqkr dot net
Description:
------------
1. The version number of the PHP package or files you are using.
Latest PHP 5.4 for Windows

2. A short script that reproduces the problem
<test script>

Sometimes, it produce this error on log file:
Warning: mb_convert_encoding(): Unable to detect character encoding in XXX.php 
on line XXX

It seems that 'auto' is not expanding to "ASCII,JIS,UTF-8,EUC-JP,SJIS".

This is a temporary fix for me:
[TYPE A]
$out_strs = mb_convert_encoding($out_strs, "UTF-8", "ASCII,JIS,UTF-8,EUC-
JP,SJIS");

or,
[TYPE B]
mb_language("Japanese");
$out_strs = mb_convert_encoding($out_strs, "UTF-8", "auto");


Test script:
---------------
I'm Englishman, so I'm added this in php.ini;
mbstring.language = English
mbstring.internal_encoding = UTF-8

And the source code is;
$out_strs = mb_convert_encoding($out_strs, "UTF-8", "auto");

Expected result:
----------------
auto SHOULD expand to ASCII,JIS,UTF-8,EUC-JP,SJIS.
Why should I change mbstring.language = English to Japs?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-24 17:11 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: moriyoshi
 [2017-07-28 19:56 UTC] nikic@php.net
-Status: Assigned +Status: Open -Type: Bug +Type: Documentation Problem -Assigned To: moriyoshi +Assigned To:
 [2017-07-28 19:56 UTC] nikic@php.net
Quoting from http://php.net/manual/en/mbstring.supported-encodings.php:

> If "auto" is set, it is expanded to the list of encodings defined per the NLS. > For instance, if the NLS is set to Japanese, the value is assumed to be
> "ASCII,JIS,UTF-8,EUC-JP,SJIS".

The default detection order that "auto" expands to depends on the language. The list you quoted is for Japanese. For English it only consists of ASCII and UTF-8.

It would be good if the documentation mentioned what the actual detection orders are for the supported languages.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 13 08:01:26 2024 UTC