How can I convert html entity 😍
to \uD83D\uDE0D
in JavaScript? (react native) (emoji )
Asked
Active
Viewed 600 times
0

Codler
- 10,951
- 6
- 52
- 65
-
@T.J.Crowder In react native – Codler Apr 20 '18 at 12:14
-
https://stackoverflow.com/questions/7394748/whats-the-right-way-to-decode-a-string-that-has-special-html-entities-in-it/7394787#7394787 – Roland Starke Apr 20 '18 at 12:16
-
@RolandStarke: If it works in React Native, yeah. (I have no idea whether it does.) – T.J. Crowder Apr 20 '18 at 12:17
2 Answers
-1
Try 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