在PHP中将这些类型的Unicode转换为UTF8 [英] Converting these types of unicode to UTF8 in PHP

查看:135
本文介绍了在PHP中将这些类型的Unicode转换为UTF8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将其转换为PHP中可读的UTF8文本

I am trying to convert this in to readable UTF8 text in PHP

Tel Aviv-Yafo (Hebrew: \u05ea\u05b5\u05bc\u05dc\u05be\u05d0\u05b8\u05d1\u05b4\u05d9\u05d1-\u05d9\u05b8\u05e4\u05d5\u05b9; Arabic: \u062a\u0644 \u0623\u0628\u064a\u0628\u200e, Tall \u02bcAb\u012bb), usually called Tel Aviv

有关如何操作的任何想法?

Any ideas on how to do so?

在线尝试了几种方法,但是找不到.

Tried several methods online, but couldn't find one.

在这种情况下,我有希伯来语和阿拉伯语的Unicode

In this case I have unicode in Hebrew and Arabic

推荐答案

其他任何答案都无法按原样完美运行. 我将它们组合在一起,并且我的加法结果是这样的:

None of the other answers work perfectly as is. I've combined them together and my addition results in this one:

$replacedString = preg_replace("/\\\\u([0-9abcdef]{4})/", "&#x$1;", $originalString);
$unicodeString = mb_convert_encoding($replacedString, 'UTF-8', 'HTML-ENTITIES');

这绝对有效:)

这篇关于在PHP中将这些类型的Unicode转换为UTF8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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