如何将 HTML 实体(十六进制)转换为 UTF-16(两对十六进制)
How to convert HTML Entity (Hexadecimal) to UTF-16 (two pair hex)
如何将 html 实体 😍
转换为 JavaScript 中的 \uD83D\uDE0D
? (反应本机)(表情符号)
这个he库可以解码
import { decode } from 'he';
decode('😍') // outputs
尝试String.fromCodePoint(...)
String.fromCodePoint(42); // "*"
String.fromCodePoint(65, 90); // "AZ"
String.fromCodePoint(0x404); // "\u0404"
String.fromCodePoint(0x2F804); // "\uD87E\uDC04"
String.fromCodePoint(194564); // "\uD87E\uDC04"
String.fromCodePoint(0x1D306, 0x61, 0x1D307) // "\uD834\uDF06a\uD834\uDF07"
String.fromCodePoint('_'); // RangeError
String.fromCodePoint(Infinity); // RangeError
String.fromCodePoint(-1); // RangeError
String.fromCodePoint(3.14); // RangeError
String.fromCodePoint(3e-2); // RangeError
String.fromCodePoint(NaN); // RangeError
如何将 html 实体 😍
转换为 JavaScript 中的 \uD83D\uDE0D
? (反应本机)(表情符号)
这个he库可以解码
import { decode } from 'he';
decode('😍') // outputs
尝试String.fromCodePoint(...)
String.fromCodePoint(42); // "*"
String.fromCodePoint(65, 90); // "AZ"
String.fromCodePoint(0x404); // "\u0404"
String.fromCodePoint(0x2F804); // "\uD87E\uDC04"
String.fromCodePoint(194564); // "\uD87E\uDC04"
String.fromCodePoint(0x1D306, 0x61, 0x1D307) // "\uD834\uDF06a\uD834\uDF07"
String.fromCodePoint('_'); // RangeError
String.fromCodePoint(Infinity); // RangeError
String.fromCodePoint(-1); // RangeError
String.fromCodePoint(3.14); // RangeError
String.fromCodePoint(3e-2); // RangeError
String.fromCodePoint(NaN); // RangeError