String codePointAt() and fromCodePoint()
The codePointAt() method returns the numeric value of the UTF-16 code point at an index of the string. The fromCodePoint() method returns a string created from one or more code points.
Overview
The codePointAt() method returns the numeric value of the UTF-16 code point at an index of the string. The fromCodePoint() method returns a string created from one or more 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 |
Syntax
'😀'.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..
co-point from generate
Number(co-point) from character generate..128512 input and emoji that display..
saroge-tpea. comparison
CharCodeAt (16bit) and codePointAt (Unicode). Difference inspect it..
Use cases
Using String codePointAt() and fromCodePoint()
The codePointAt() method returns the numeric value of the UTF-16 code point at an index of the string. The fromCodePoint() method returns a string created from one or more code points.
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.
Related links
Powered by web-features