Bug #68119 [Opn->Nab]: mb_detect_encoding can not detect encoding rightly

From: Date: Tue, 30 Sep 2014 02:07:11 +0000
Subject: Bug #68119 [Opn->Nab]: mb_detect_encoding can not detect encoding rightly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187762@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 Updated by: requinix@php.net Reported by: zf at ancientrock dot org Summary: mb_detect_encoding can not detect encoding rightly -Status: Open +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: 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: ռ¥ Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#187762) next »