Skip to content

Commit d95f42d

Browse files
michaelficarraljharb
authored andcommitted
Normative: integrate well-formed Unicode strings proposal (#3039)
1 parent 38e3cf9 commit d95f42d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

spec.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34033,6 +34033,16 @@ <h1>String.prototype.indexOf ( _searchString_ [ , _position_ ] )</h1>
3403334033
</emu-note>
3403434034
</emu-clause>
3403534035

34036+
<emu-clause id="sec-string.prototype.iswellformed">
34037+
<h1>String.prototype.isWellFormed ( )</h1>
34038+
<p>This method performs the following steps when called:</p>
34039+
<emu-alg>
34040+
1. Let _O_ be ? RequireObjectCoercible(*this* value).
34041+
1. Let _S_ be ? ToString(_O_).
34042+
1. Return IsStringWellFormedUnicode(_S_).
34043+
</emu-alg>
34044+
</emu-clause>
34045+
3403634046
<emu-clause id="sec-string.prototype.lastindexof">
3403734047
<h1>String.prototype.lastIndexOf ( _searchString_ [ , _position_ ] )</h1>
3403834048
<emu-note>
@@ -34606,6 +34616,27 @@ <h1>String.prototype.toUpperCase ( )</h1>
3460634616
</emu-note>
3460734617
</emu-clause>
3460834618

34619+
<emu-clause id="sec-string.prototype.towellformed">
34620+
<h1>String.prototype.toWellFormed ( )</h1>
34621+
<p>This method returns a String representation of this object with all leading surrogates and trailing surrogates that are not part of a surrogate pair replaced with U+FFFD (REPLACEMENT CHARACTER).</p>
34622+
<p>It performs the following steps when called:</p>
34623+
<emu-alg>
34624+
1. Let _O_ be ? RequireObjectCoercible(*this* value).
34625+
1. Let _S_ be ? ToString(_O_).
34626+
1. Let _strLen_ be the length of _S_.
34627+
1. Let _k_ be 0.
34628+
1. Let _result_ be the empty String.
34629+
1. Repeat, while _k_ &lt; _strLen_,
34630+
1. Let _cp_ be CodePointAt(_S_, _k_).
34631+
1. If _cp_.[[IsUnpairedSurrogate]] is *true*, then
34632+
1. Set _result_ to the string-concatenation of _result_ and 0xFFFD (REPLACEMENT CHARACTER).
34633+
1. Else,
34634+
1. Set _result_ to the string-concatenation of _result_ and UTF16EncodeCodePoint(_cp_.[[CodePoint]]).
34635+
1. Set _k_ to _k_ + _cp_.[[CodeUnitCount]].
34636+
1. Return _result_.
34637+
</emu-alg>
34638+
</emu-clause>
34639+
3460934640
<emu-clause id="sec-string.prototype.trim">
3461034641
<h1>String.prototype.trim ( )</h1>
3461134642
<p>This method interprets a String value as a sequence of UTF-16 encoded code points, as described in <emu-xref href="#sec-ecmascript-language-types-string-type"></emu-xref>.</p>

0 commit comments

Comments
 (0)