JS: String.fromCharCode (id to char) 👎
- 🟢 tip: better is String.fromCodePoint
String.fromCharCode(char_id_1, char_id_2, etc)-
Turn each Char ID into a character and join them, return a string. char_id is a integer.
🛑 warning: does not work if char_id is greater than 65535. If it is greater than 65535, a value of modulo(char_id, 2^16) is used.
🛑 warning: string methods do not work the way you think if it contains characters outside of Unicode Basic Multilingual Plane (e.g. emoji 🦋.). See JS: String Index Code Unit
/* convert sequence of unicode codepoint to string. 97 is the codepoint for letter a. 98 is the codepoint for letter b. */ console.log(String.fromCharCode(97, 98)); // ab // String.fromCharCode() does not work for emoji or other rare unicode char // try to generate the butterfly 🦋 char console.log(String.fromCharCode(129419)); // 曆 // result is not what we want /* 🦋 Name: BUTTERFLY ID 129419 HEXD 1F98B UTF8 F0 9F A6 8B UTF16 D83E DD8B */