

CODEPOINTS CODE
HexCodePoints.push(codePoint.toString(16)) Ĭonsole.log(codePoints) // Ĭonsole.log(hexCodePoints) // In character encoding terminology, a code point, codepoint or code position is a numerical value that maps to a specific character.
You can get the code points for each element in this ZWJ sequence in the following way:Ĭonst codePoint = dePointAt(0) Class String has the following methods that create streams: IntStream chars() IntStream codePoints() StreamYou can do so by using the for.of loop or () (or anything which correctly iterates UTF-16 surrogates), and use codePointAt(0) to get the code point of each element.Ĭonsider, for example, ZWJ emoji "👨👩👧👦" ("family: man, woman, girl, boy") which is a combination of "👨 👩 👧 👦" (i.e. However, you would need to loop over the elements of ZWJ sequence to get code points of each element. codePointAt(1))įurthermore, this even works with ZWJ (zero-width joiner sequences). a surrogate pair), the following values are returned based on the argument you supply to the method: This works because when you use the () method on a character composed of UTF-16 high and low surrogates (i.e. You can verify the result by using omCodePoint(), like so: For example, consider a character with " surrogate pair": This also works for characters that are beyond the BMP (Basic Multilingual Plane). You can verify the result by using omCodePoint(), for example, in the following way: The table below shows two characters encoded in a code page and Unicode, using UTF-16, UTF-32, and UTF-8. You can get the respective Unicode code point of a character that lies in the BMP (Basic Multilingual Plane) by simply using the () method, for example, like so:Ĭonst hexCodePoint = codePoint.toString(16)
