dongwen7371 2015-12-01 10:32
浏览 51

在PHP中将Unicode字符转换为文本无效

I am trying to convert Unicode character to text in PHP. But the string is the mixture of Unicode characters and text. But it is not working.

I followed this link (Unicode character in PHP string)

<?php

   $unicodeChar = "{'singer': u'', 'name': u'\\\\u101c\\\\u1031\\\\u1011\\\\u1032\\\\u101c\\\\u103d\\\\u103e\\\\u1004\\\\u1037\\\\u103a\\\\u101c\\\\u102d\\\\u102f\\\\u1000\\\\u103a'}\\
\\
    artist          : Thar Gyi\\
    album           : Sal Pone Ta Pone\\
    genre           : R&B\\
    copyright       : MyanmarSongs.NET\\
    track           : 1\\
    title           : Lay Htal Hlwint Lite";
   echo json_decode('"'.$unicodeChar.'"');
   echo mb_convert_encoding($unicodeChar, 'UTF-8', 'HTML-ENTITIES'); 
   echo mb_convert_encoding($unicodeChar, 'UTF-8', 'UTF-16BE'); showing nothing

?>

All the above scenarios are not working when the value is the mixtures of Unicode characters and text like I used. But it is working when the value is so simple like this:

$unicodeChar = '\u1000';
echo json_decode('"'.$unicodeChar.'"');

How can I achieve this?

  • 写回答

1条回答 默认 最新

  • dsjklb0205 2015-12-01 10:42
    关注

    use following code

    $unicodeChar = '\u1000';
    echo json_decode('"'.$unicodeChar.'"');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘