Skip to content

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

Open
@smallearth

Description

@smallearth

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions