JS: String.fromCharCode (Char 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 */
JavaScript. String, Char, Encoding, Hexadecimal
- JS: String Index Code Unit
- JS: Convert Decimal, Hexadecimal
- JS: String.prototype.codePointAt (Char to Char ID) ❌
- JS: String.fromCodePoint (Char ID to Char)
- JS: Char to UTF-8 Encoding 📜
- JS: Char to UTF-16 Encoding 📜
- JS: String.prototype.charCodeAt (Char to Char ID) ❌
- JS: String.prototype.charAt (Extract Char at Index) ❌
- JS: String.prototype.at (Extract Char at Index)
- JS: String.fromCharCode (Char ID to Char) ❌
JS String.prototype
- JS: String.prototype.constructor
- JS: String.prototype.length
- JS: String.prototype.at (Extract Char at Index)
- JS: String.fromCharCode (Char ID to Char) ❌
- JS: String.prototype.concat
- JS: String.prototype.repeat
- JS: String.prototype.trim
- JS: String.prototype.trimStart
- JS: String.prototype.trimEnd
- JS: String.prototype.padStart
- JS: String.prototype.padEnd
- JS: String.prototype.slice
- JS: String.prototype.substring ❌
- JS: String.prototype.substr
- JS: String.prototype.indexOf
- JS: String.prototype.lastIndexOf
- JS: String.prototype.includes
- JS: String.prototype.startsWith
- JS: String.prototype.endsWith
- JS: String.prototype.search
- JS: String.prototype.match
- JS: String.prototype.matchAll
- JS: String.prototype.replace
- JS: String.prototype.split
- JS: String.prototype.toLowerCase
- JS: String.prototype.charAt (Extract Char at Index) ❌
- JS: String.prototype.charCodeAt (Char to Char ID) ❌
- JS: String.prototype.codePointAt (Char to Char ID) ❌