[PHP-BUG] Bug #71183 [NEW]: mb_detect_encoding wrong with Windows-1252
[email protected] ("martin at sutunam dot com")
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
From: martin at sutunam dot com
Operating system: Ubuntu
PHP version: 5.5.30
Package: mbstring related
Bug Type: Bug
Bug description:mb_detect_encoding wrong with Windows-1252
Description:
------------
mb_detect_encoding doesn't detect string with Windows-1252 ( cp1252 )
encoding.
The function is supposed to return the first compatible encoding within
the provided encoding list as second param.
Even with an ASCII string like 'aaa', it refuse the Windows-1252
encoding.
Test script:
---------------
<?php
$enc = 'Windows-1252';
if (!in_array($enc, mb_list_encodings())) {
die($enc.' not supported');
}
$val = '100 '. 0x80; // € sign in cp1252
echo mb_detect_encoding($val, $enc.',ISO-8859-1', true).PHP_EOL;
$val = 'aaa';
echo mb_detect_encoding($val, $enc.',ISO-8859-1', true).PHP_EOL;
Expected result:
----------------
Windows-1252
Windows-1252
Actual result:
--------------
ISO-8859-1
ISO-8859-1
--
Edit bug report at https://bugs.php.net/bug.php?id=71183&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71183&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71183&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71183&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71183&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71183&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71183&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71183&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71183&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71183&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71183&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71183&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71183&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71183&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71183&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71183&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71183&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71183&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71183&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71183&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71183&r=mysqlcfg