我将unicode字符嵌入到字符串中,如下所示:
64\u00be w × 19\u00bd d × 16\u00be h in (164 × 50 × 43 cm)现在我想像这样转换它们:
64¾ w × 19½ d × 16¾ h in 164 × 50 × 43 cm到目前为止,我尝试了以下方法:
$desc = '64\u00be w × 19\u00bd d × 16\u00be h in (164 × 50 × 43 cm)';
echo mb_convert_encoding($desc, 'ASCII', 'HTML-ENTITIES')
echo html_entity_decode( mb_convert_encoding ( $desc, 'HTML-ENTITIES', 'ASCII' )但是两者都不能转换unicode字符,我在这里缺少什么?
发布于 2018-08-02 12:57:39
你可以像这样使用一个简单的hack (它不应该有任何性能问题):
$a = '64\u00be w × 19\u00bd d × 16\u00be h in (164 × 50 × 43 cm)';
$html = json_decode('"' . $a . '"');
echo $html;https://stackoverflow.com/questions/51644103
复制相似问题