duanhuo3392 2014-07-25 07:32
浏览 54
已采纳

utf8没有在PHP中转换字符串

Hello i have german client and i am getting string with german alphabet which i am trying to display properly in output.I tried utf8_encode to convert string but not working for me.

Code:

    echo "Desc Short=>". utf8_encode($obj->Desc_Short) . "<br>
";
    echo "Desc Long=>". utf8_encode($obj->Desc_Long) . "<br>
";

Output:

Desc Short=>Ablagefach mittig in Gepäckraumtrennwand;ESACO_UG(122)
Desc Long=>Ablagefach mittig in Gepäckraumtrennwand inkl. verschiebbarem Haltenetz
  • 写回答

3条回答 默认 最新

  • duanfei1975 2014-07-25 07:47
    关注

    It seems you need to simply use utf8_decode and use php header to set encoding (or set encoding in HTML document).

    For the following code:

    <?php
    
    header( 'Content-type: text/html; charset=utf-8' );
    $x = 'Ablagefach mittig in Gepäckraumtrennwand;ESACO_UG(122)';
    
    echo utf8_decode($x);
    

    Output for this is:

    Ablagefach mittig in Gepäckraumtrennwand;ESACO_UG(122)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?