simple_html_dom icon indicating copy to clipboard operation
simple_html_dom copied to clipboard

iconv(): Detected an illegal character in input string

Open smallearth opened this issue 10 years ago • 1 comments

I encountered this problem when I use this code.

iconv(): Detected an illegal character in input string

Then i change

$converted_text = iconv($sourceCharset, $targetCharset//IGNORE, $text);

to

$converted_text = iconv($sourceCharset, "$targetCharset//IGNORE", $text); 

And then pop up the follow error.

iconv(): Detected an incomplete multibyte character in input string.

Final i change the code to

$converted_text = htmlentities($text, ENT_QUOTES, $targetCharset);

It worked fine.

Is there a better way to solve this problem.

smallearth avatar Dec 07 '15 15:12 smallearth

Use mb_convert_encoding instead, like this:

mb_convert_encoding(strip_tags($text, $targetCharset, $sourceCharset)

jajupmochi avatar Apr 02 '18 10:04 jajupmochi