You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Returns a nonnegative integer Number less than 0x110000 that is the code point value of the UTF-16 encoded code point (<emu-xref href="#sec-ecmascript-language-types-string-type"></emu-xref>) starting at the string element at index _pos_ within the String resulting from converting this object to a String. If there is no element at that index, the result is *undefined*. If a valid UTF-16 <emu-xref href="#surrogate-pair"></emu-xref> does not begin at _pos_, the result is the code unit at _pos_.</p>
28303
+
<p>Returns a nonnegative integer Number less than or equal to 0x10FFFF that is the code point value of the UTF-16 encoded code point (<emu-xref href="#sec-ecmascript-language-types-string-type"></emu-xref>) starting at the string element at index _pos_ within the String resulting from converting this object to a String. If there is no element at that index, the result is *undefined*. If a valid UTF-16 <emu-xref href="#surrogate-pair"></emu-xref> does not begin at _pos_, the result is the code unit at _pos_.</p>
28304
28304
</emu-note>
28305
28305
<p>When the `codePointAt` method is called with one argument _pos_, the following steps are taken:</p>
1. If _position_ < 0 or _position_ ≥ _size_, return *undefined*.
28312
-
1. Let _first_ be the numeric value of the code unit at index _position_ within the String _S_.
28313
-
1. If _first_ < 0xD800 or _first_ > 0xDBFF or _position_ + 1 = _size_, return _first_.
28314
-
1. Let _second_ be the numeric value of the code unit at index _position_ + 1 within the String _S_.
28315
-
1. If _second_ < 0xDC00 or _second_ > 0xDFFF, return _first_.
28316
-
1. Return UTF16Decode(_first_, _second_).
28312
+
1. Let _first_ be the code unit at index _position_ within the String _S_.
28313
+
1. If _first_ is not a <emu-xref href="#leading-surrogate"></emu-xref> or if _position_ + 1 = _size_, return the numeric value of _first_.
28314
+
1. Let _second_ be the code unit at index _position_ + 1 within the String _S_.
28315
+
1. If _second_ is not a <emu-xref href="#trailing-surrogate"></emu-xref>, return the numeric value of _first_.
28316
+
1. Let _cp_ be UTF16Decode(_first_, _second_).
28317
+
1. Return the code point value of _cp_.
28317
28318
</emu-alg>
28318
28319
<emu-note>
28319
28320
<p>The `codePointAt` function is intentionally generic; it does not require that its *this* value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
1. Let _first_ be the numeric value of the code unit at index _position_ within _s_.
29116
-
1. If _first_ < 0xD800 or _first_ > 0xDBFF or _position_ + 1 = _len_, let _resultString_ be the String value consisting of the single code unit _first_.
29116
+
1. Let _first_ be the code unit at index _position_ within _s_.
29117
+
1. If _first_ is not a <emu-xref href="#leading-surrogate"></emu-xref> or if _position_ + 1 = _len_, let _resultString_ be the String value consisting of the single code unit _first_.
29117
29118
1. Else,
29118
-
1. Let _second_ be the numeric value of the code unit at index _position_ + 1 within the String _s_.
29119
-
1. If _second_ < 0xDC00 or _second_ > 0xDFFF, let _resultString_ be the String value consisting of the single code unit _first_.
29119
+
1. Let _second_ be the code unit at index _position_ + 1 within the String _s_.
29120
+
1. If _second_ is not a <emu-xref href="#trailing-surrogate"></emu-xref>, let _resultString_ be the String value consisting of the single code unit _first_.
29120
29121
1. Else, let _resultString_ be the string-concatenation of the code unit _first_ and the code unit _second_.
29121
29122
1. Let _resultSize_ be the number of code units in _resultString_.
29122
29123
1. Set _O_.[[StringIteratorNextIndex]] to _position_ + _resultSize_.
0 commit comments