drdyszuy488152 2013-01-20 19:16
浏览 88
已采纳

通过PHP将阿拉伯数字html实体转换为字符

I have some string with arabic encoded and ukrainian (cyrillyc) words, like this:

$string = "اِئْتِلافِيٌّ - коаліційний, гармонійний;";

and I want to get characters (arabic) instead all this "&#xxxx;"`s.

If I putting this string into html, I'm getting exactly what i want: "اِئْتِلافِيٌّ - коаліційний, гармонійний;"

But when I use html_entitis_decode, it does nothing. (mb because arabic encoding does not supports with this function, just basic ASCII). So, plz tell me what should I do to get same result as browser interpreter?

  • 写回答

1条回答 默认 最新

  • douchungu0859 2013-01-20 19:38
    关注

    Your PHP version is probably older than 5.4.0, thus html_entity_decode is not using UTF-8.

    Encoding to use. If omitted, the default value for this argument is ISO-8859-1 in versions of PHP prior to 5.4.0, and UTF-8 from PHP 5.4.0 onwards.

    http://php.net/manual/en/function.html-entity-decode.php


    Try the following:

    $decoded_string = html_entity_decode($string, ENT_COMPAT | ENT_HTML401, "UTF-8");
    

    View output here on Codepad

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 像这种代码要怎么跑起来?
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件