Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iconv(): Detected an illegal character in input string #4

Open
smallearth opened this issue Dec 7, 2015 · 1 comment
Open

iconv(): Detected an illegal character in input string #4

smallearth opened this issue Dec 7, 2015 · 1 comment

Comments

@smallearth
Copy link

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.

@jajupmochi
Copy link

Use mb_convert_encoding instead, like this:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants