|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-11-06 21:45 UTC] trollofdarkness at gmail dot com
Description:
------------
Hi everyone,
I have been, since I think the version 5.3.x is out (and still with 5.4.8),
experiencing issues with iconv.
Especially, when an illegal character is encountered and the //IGNORE flag is
set on the target charset, the function returns FALSE instead of just skipping
this character.
This is problematic because if a single character in a 50 000 chars long string
is "illegal" then the output is nothing, just for one char...
It does not happen with the TRANSLIT flag.
I experienced that with UTF8 (from) and ISO-8859-15 (to) charsets, I did not
test with other ones. Below is an example to reproduce the bug.
Note : I saw there are other bug reports about similar issues, but they're all
saying the string is cut... In my case, it literally returns false. So, might be
different?
Test script:
---------------
<?php
$str = "
foo
è
foo
";
$result = iconv("UTF-8", "ISO-8859-15"."//IGNORE", $str);
var_dump($result); // false, instead of "foo ... foo"
?>
Expected result:
----------------
foo
foo
Actual result:
--------------
false
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
Hi. Will this bug be resolved? I use PHP on Debian and i cannot upgrade Debian to version 7.x and PHP to 5.5.x (via dotdeb.org) because of this problem. Functions, which uses glibc (like iconv or htmlspecialchars) returns empty string. How to test iconv: function testIconv1(){ set_error_handler('doNothing'); $r = iconv('utf-8', 'ascii//IGNORE', "\xCE\xB1" . str_repeat('a', 9000)); restore_error_handler(); if ($r === false) { $code = "UNUSABLE"; } elseif (($c = strlen($r)) < 9000) { $code = "TRUNCATES"; } elseif ($c > 9000) { $code = "BUGGY"; } else { $code = "OK"; } return $code; } function doNothing(){} echo testIconv1(); how to test htmlspecialchars: var_dump(htmlspecialchars('żółw')); //returns an empty string I can't upgrade serwer software because of this more than 1 year old bug. Please, do something with that (i would like to use PHP 5.3 instead of PHP 5.3). Regards, Daniel