String codePointAt() and fromCodePoint()
The codePointAt() method of String values returns a non-negative integer that is the Unicode code point value of the character starting at the given index. Note that the index is still based on UTF-16 code units, not Unicode code points.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 41 | 12 | 29 | 9 | 41 | 9 | |
| Built-in object | ||||||
| The String.fromCodePoint() static method returns a string created from the specified sequence of code points. | 41 | 12 | 29 | 9 | 41 | 9 |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Syntax
JAVASCRIPT
'😀'.codePointAt(0); // 128512
String.fromCodePoint(128512); // '😀'
// charCodeAt cannot handle surrogate pairs correctly
'😀'.charCodeAt(0); // 55357 (upper surrogate only) Live demo
co-point. Read
Inputcharacter. Unicode co-point display..emoji also positivecheck in..
PreviewFullscreen
co-point from generate
Number(co-point) from character generate..128512 input and emoji that display..
PreviewFullscreen
saroge-tpea. comparison
CharCodeAt (16bit) and codePointAt (Unicode). Difference inspect it..
PreviewFullscreen
Use cases
-
Using String codePointAt() and fromCodePoint()
The codePointAt() method of String values returns a non-negative integer that is the Unicode code point value of the character starting at the given index.
Cautions
- No specific concerns. Stable across all major browsers.
Accessibility
- When updating the DOM dynamically, announce important changes to assistive technology with aria-live regions.