note 76396 added to function.mb-check-encoding
| From: | OlexaRiznyk at osu1 dot php dot net | Date: | Fri, 13 Jul 2007 06:53:34 +0000 |
| Subject: | note 76396 added to function.mb-check-encoding | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128431@lists.php.net to get a copy of this message | ||
This function returns true incorrectly sometimes (at least when internal encoding is UTF-8 and
encoding being checked for is Windows-1251, and PHP version 4.4.4 on FreeBSD 6.2 STABLE). This bug
was not answered in bug reporting yet, so here is a workaround:
Instead of checking for this:
<?php
mb_check_encoding($var, $destination_encoding)
?>
check for this:
<?php
mb_check_encoding($var, $destination_encoding) && mb_substr_count($var, '?',
$source_encoding) == mb_substr_count(mb_convert_encoding($var, $destination_encoding,
$source_encoding), '?', $destination_encoding)
?>
The idea is to count question mark characters ('?') in original value and converted value,
because mb_convert_encoding function uses question marks to substitute characters that are not valid
in destination encoding.
----
Server IP: 69.147.83.197
Probable Submitter: 77.123.32.227
----
Manual Page -- http://www.php.net/manual/en/function.mb-check-encoding.php
Edit -- https://master.php.net/note/edit/76396
Del: integrated -- https://master.php.net/note/delete/76396/integrated
Del: useless -- https://master.php.net/note/delete/76396/useless
Del: bad code -- https://master.php.net/note/delete/76396/bad+code
Del: spam -- https://master.php.net/note/delete/76396/spam
Del: non-english -- https://master.php.net/note/delete/76396/non-english
Del: in docs -- https://master.php.net/note/delete/76396/in+docs
Del: other reasons-- https://master.php.net/note/delete/76396
Reject -- https://master.php.net/note/reject/76396
Search -- https://master.php.net/manage/user-notes.php