#47876 [Com]: Wrong mb_detect_encoding() with string "chráany"
| From: | FrancS at seznam dot cz | Date: | Tue, 14 Apr 2009 08:25:22 +0000 |
| Subject: | #47876 [Com]: Wrong mb_detect_encoding() with string "chráany" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-135793@lists.php.net to get a copy of this message | ||
ID: 47876
Comment by: FrancS at seznam dot cz
Reported By: FrancS at seznam dot cz
Status: Feedback
Bug Type: mbstring related
Operating System: Windows XP
PHP Version: 5.2.9
New Comment:
It is because I want to use it for finding which encoding I have in
input string. It is posible that some user send some data in one of
these encoding....utf-8, windows-1250 and ISO-8859-2.
It is important to me to find in which encoding it is in.
Previous Comments:
------------------------------------------------------------------------
[2009-04-13 17:58:20] jani@php.net
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");
------------------------------------------------------------------------
[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