Hi, I saw this question asked around the traps, but so far none of the examples that I saw helped me when I tried them. I get the error "iconv (): an incomplete multibyte character was found in the input line , on a specific input. When using the following functions together. Do you have any idea how this error message will disappear. I am trying to convert the input mixed-coding string in UTF8.
function ConvertToUTF8($text){ return iconv(mb_detect_encoding($text, mb_detect_order(), false), "UTF-8//IGNORE", $text); }
EDITOR: Hello everyone after we looked around the following:
function ConvertToUTF8($text){ $encoding = mb_detect_encoding($text, mb_detect_order(), false); if($encoding == "UTF-8") { $text = mb_convert_encoding($text, 'UTF-8', 'UTF-8'); } $out = iconv(mb_detect_encoding($text, mb_detect_order(), false), "UTF-8//IGNORE", $text); return $out; }
You may be able to improve it, but it fixed our mistake.
source share