iconv():在输入字符串中检测到不完整的多字节字符 [英] iconv(): Detected an incomplete multibyte character in input string

查看:197
本文介绍了iconv():在输入字符串中检测到不完整的多字节字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到有关陷阱的问题,但是到目前为止,当我尝试使用这些示例时,我所看到的所有示例都没有对我有所帮助.我收到错误"iconv():在某些输入上,在输入字符串" 中检测到不完整的多字节字符.一起使用以下功能时.您对如何获取此错误消息有任何想法.我正在尝试将混合编码的输入字符串转换为UTF8.

Hi I have seen this question asked around the traps, but so far none of the examples I have seen have helped me, when I tried them. I am getting the error "iconv(): Detected an incomplete multibyte character in input string ", on certain input. When using the following functions together. Do you have any ideas as to how to get this error message to go away. I am attempting to convert an input string with mixed encoding to UTF8.

    function ConvertToUTF8($text){
         return iconv(mb_detect_encoding($text, mb_detect_order(), false), "UTF-8//IGNORE", $text);
    }

大家好,环顾四周,以下内容为我们工作了:

Hi all after some looking around the following worked for us:

 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 might be able to improve it, but it fixed our error.

推荐答案

好的,这对我们有用.

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;
}

这篇关于iconv():在输入字符串中检测到不完整的多字节字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆