#47876 [Opn->Fbk]: Wrong mb_detect_encoding() with string "chráany"

From: Date: Mon, 13 Apr 2009 17:58:22 +0000
Subject: #47876 [Opn->Fbk]: Wrong mb_detect_encoding() with string "chráany"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-135778@lists.php.net to get a copy of this message
ID: 47876 Updated by: jani@php.net Reported By: FrancS at seznam dot cz -Status: Open +Status: Feedback Bug Type: mbstring related Operating System: Windows XP PHP Version: 5.2.9 New Comment: What if you pass the function the possible encodings and never "auto" which always has UTF-8 as first. Something like like this: echo mb_detect_encoding($str, "SJIS, sjis-win"); Previous Comments: ------------------------------------------------------------------------ [2009-04-02 10:13:08] FrancS at seznam dot cz I look again on it and problem is with "᚝" in word with no other accent chars in it. ------------------------------------------------------------------------ [2009-04-02 10:08:07] FrancS at seznam dot cz Description: ------------ Hi, today I discover a problem with mb function mb_detect_encoding(). I have a string "chr᚝any" in czech language. It seems that this function everytime return UTF-8 encoding, even if I load the text from a file with encoding "windows-1250" or "ISO-8859-2". Reproduce code: --------------- // test.txt is text file with charset "windows-1250" or "ISO-8859-2" $string = file_get_contents('test.txt'); var_dump(mb_detect_encoding($string, mb_list_encodings(), true)); Expected result: ---------------- SJIS Actual result: -------------- utf-8 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47876&edit=1

« previous php.bugs (#135778) next »