PHP - UTF-16 到 UTF-8(十六进制)转换

发布于 2024-08-29 07:03:32 字数 123 浏览 2 评论 0原文

是否可以转换UTF-16
U+610F
样式字符转为 UTF-8(十六进制)
E6848F
使用PHP?

UTF-8 字符是“意”

Is it possible to convert UTF-16
U+610F
style character to UTF-8 (hex)
E6848F
using PHP ?

UTF-8 character is '意'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青巷忧颜 2024-09-05 07:03:32

根据 chr 手册页中的评论,一个转换序数的快速技巧将字符数转换为 UTF-8 字节序列:

function unichr($u) {
    return mb_convert_encoding('&#' . intval($u) . ';', 'UTF-8', 'HTML-ENTITIES');
}

// unichr(0x610F) -> "\xE6\x84\x8F"

From the comments in the chr man page, one quick hack for turning an ordinal character number into a UTF-8 byte sequence:

function unichr($u) {
    return mb_convert_encoding('&#' . intval($u) . ';', 'UTF-8', 'HTML-ENTITIES');
}

// unichr(0x610F) -> "\xE6\x84\x8F"
南风起 2024-09-05 07:03:32

php 有 unicode 编码和解码..让你尝试一下

utf8_decode(); or utf8_encode();

php have unicode encoding and decoding.. let u try on that

utf8_decode(); or utf8_encode();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文