Bug #68119 [Nab]: mb_detect_encoding can not detect encoding rightly
| From: | zf at ancientrock dot org | Date: | Tue, 30 Sep 2014 02:23:29 +0000 |
| Subject: | Bug #68119 [Nab]: mb_detect_encoding can not detect encoding rightly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187764@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68119&edit=1
ID: 68119
User updated by: zf at ancientrock dot org
Reported by: zf at ancientrock dot org
Summary: mb_detect_encoding can not detect encoding rightly
Status: Not a bug
Type: Bug
Package: mbstring related
Operating System: Linux
PHP Version: master-Git-2014-09-30 (Git)
Block user comment: N
Private report: N
New Comment:
It's really a bug, One word can only had one encoding, can not be all encoding the same time.
or we can not coding right
Previous Comments:
------------------------------------------------------------------------
[2014-09-30 02:11:44] requinix@php.net
>EUC-CN: 媼ä¿
Probably not right, actually, taking a second look at my source. But D5BCC2A5 is still a valid byte
sequence for that encoding.
------------------------------------------------------------------------
[2014-09-30 02:07:11] requinix@php.net
I get E58DA0E6A5BC as invalid EUC-CN. http://3v4l.org/rEcG5
But the rest is correct. Just because it's not the string you expect doesn't mean
it's invalid.
E58DA0E6A5BC as
CP936: éç³ã¼
EUC-CN: invalid
UTF-8: å æ¥¼
D5BCC2A5 as
CP936: å æ¥¼
EUC-CN: 媼ä¿
UTF-8: ռ¥
------------------------------------------------------------------------
[2014-09-30 00:55:13] zf at ancientrock dot org
Description:
------------
mb_detect_encoding can not detect encoding rightly
$str1 = hex2bin('e58da0e6a5bc');
$str2 = hex2bin('d5bcc2a5');
we want to detect encoding to see what's it!
CP936? EUC-CN ? UTF-8?
Test script:
---------------
$str1 = hex2bin('e58da0e6a5bc');
$str2 = hex2bin('d5bcc2a5');
var_dump(mb_detect_encoding($str1, 'CP936', true));
var_dump(mb_detect_encoding($str1, 'EUC-CN', true));
var_dump(mb_detect_encoding($str1, 'UTF-8', true));
var_dump(mb_detect_encoding($str2, 'CP936', true));
var_dump(mb_detect_encoding($str2, 'EUC-CN', true));
var_dump(mb_detect_encoding($str2, 'UTF-8', true));
Expected result:
----------------
$str1 was UTF-8 encoding,
$str2 was CP936 encoding.
Actual result:
--------------
All detect return true
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68119&edit=1