Ma *_*eng 0 javascript unicode emoji
有些文字包含六位数的表情符号.我需要通过JavaScript将其转码为Unicode.
像这样:
origin: 328054
Unicode: \ue052 ( U+E052 'the dog face' Emoji )
Run Code Online (Sandbox Code Playgroud)
如何通过Javascript将这六位数的表情符号代码转码为Unicode?
来源:328054
我不知道你的意思.如果处理十进制,则U + 50176不是有效的Unicode字符.如果处理为十六进制,则它位于Unicode可以表示的代码点范围之外.
Unicode:\ ue052(U + E052)
U + E052保留供私人使用.你不是那个意思.软银似乎已经使用它来编码Dog Face表情符号.除非你住在日本,并使用他们的网络,否则它几乎不适合你.
'狗脸'表情符号
分配给U + 1F436 : .
How can I encode this in Javascript?
JavaScript uses UTF-16, and since your code point is higher than U+D7FF, you will need two characters to encode it as a surrogate pair. You still can easily get the string from the code point by using String.fromCodePoint以下命令从代码点轻松获取字符串:
var df = String.fromCodePoint(0x1F436);
df.length; // 2
Run Code Online (Sandbox Code Playgroud)
您可以使用以下charCodeAt方法获取从该字符串中转义所需的字符代码:
String.fromCodePoint(0x1F436).charCodeAt(0).toString(16) // d83d
String.fromCodePoint(0x1F436).charCodeAt(1).toString(16) // dc36
Run Code Online (Sandbox Code Playgroud)
所以你似乎追求的JS字符串文字是"\ud83d\udc36".
| 归档时间: |
|
| 查看次数: |
558 次 |
| 最近记录: |