generated from tc39/template-for-proposals
-
Notifications
You must be signed in to change notification settings - Fork 4
/
spec.html
46 lines (43 loc) · 1.84 KB
/
spec.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<html lang="en-GB-oxendict">
<meta charset="utf-8">
<pre class="metadata">
title: Well-Formed Unicode Strings
status: proposal
stage: 4
location: https://tc39.es/proposal-is-usv-string
copyright: false
contributors: Guy Bedford, Bradley Farias, Michael Ficarra
</pre>
<emu-clause number="22.1.3" id="sec-properties-of-the-string-prototype-object">
<h1>Properties of the String Prototype Object</h1>
<emu-clause number="10" id="sec-string.prototype.iswellformed">
<h1>String.prototype.isWellFormed ( )</h1>
<p>This method performs the following steps when called:</p>
<emu-alg>
1. Let _O_ be ? RequireObjectCoercible(*this* value).
1. Let _S_ be ? ToString(_O_).
1. Return IsStringWellFormedUnicode(_S_).
</emu-alg>
</emu-clause>
<emu-clause number="11" id="sec-string.prototype.towellformed">
<h1>String.prototype.toWellFormed ( )</h1>
<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>
<p>It performs the following steps when called:</p>
<emu-alg>
1. Let _O_ be ? RequireObjectCoercible(*this* value).
1. Let _S_ be ? ToString(_O_).
1. Let _strLen_ be the length of _S_.
1. Let _k_ be 0.
1. Let _result_ be the empty String.
1. Repeat, while _k_ < _strLen_,
1. Let _cp_ be CodePointAt(_S_, _k_).
1. If _cp_.[[IsUnpairedSurrogate]] is *true*, then
1. Set _result_ to the string-concatenation of _result_ and 0xFFFD (REPLACEMENT CHARACTER).
1. Else,
1. Set _result_ to the string-concatenation of _result_ and UTF16EncodeCodePoint(_cp_.[[CodePoint]]).
1. Set _k_ to _k_ + _cp_.[[CodeUnitCount]].
1. Return _result_.
</emu-alg>
</emu-clause>
</emu-clause>