Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit 36fbcf0

Browse files
committed
fixup: code points instead of code units
1 parent 6fc628f commit 36fbcf0

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

spec.emu

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ contributors: Jordan Harband
3030
1. Let _escapedList_ be a new empty List.
3131
1. For each code point _c_ in _cpList_, do
3232
1. If _escapedList_ is empty and _c_ is matched by |DecimalDigit|, then
33-
1. Append code unit U+005C (REVERSE SOLIDUS) to _escapedList_.
34-
1. Append code unit U+0078 (LATIN SMALL LETTER X) to _escapedList_.
35-
1. Append code unit U+0033 (DIGIT THREE) to _escapedList_.
33+
1. Append code point U+005C (REVERSE SOLIDUS) to _escapedList_.
34+
1. Append code point U+0078 (LATIN SMALL LETTER X) to _escapedList_.
35+
1. Append code point U+0033 (DIGIT THREE) to _escapedList_.
3636
1. Append _c_ to _escapedList_.
3737
1. Else,
38-
1. Append the code units in EncodeForRegExpEscape(_c_) to _escapedList_.
38+
1. Append the code points in EncodeForRegExpEscape(_c_) to _escapedList_.
3939
1. Return CodePointsToString(_escapedList_).
4040
</emu-alg>
4141

@@ -47,32 +47,37 @@ contributors: Jordan Harband
4747
<emu-clause id="sec-encode" type="abstract operation">
4848
<h1>
4949
EncodeForRegExpEscape (
50-
_c_: a code unit,
51-
): a List of code units
50+
_c_: a code point,
51+
): a List of code points
5252
</h1>
5353
<dl class="header">
5454
<dt>description</dt>
5555
<dd>If the code unit represents a RegExp punctuator that needs escaping, or ASCII whitespace, it produces the code units for *"\x"* followed by the relevant escape code. If the code unit represents non-ASCII white space, it produces the code units for *"\u"* followed by the relevant escape code. Otherwise, it returns a List containing the original code unit.</dd>
5656
</dl>
5757

5858
<emu-alg>
59-
1. Let _codeUnits_ be a new empty List.
59+
1. Let _codePoints_ be a new empty List.
6060
1. Let _punctuators_ be the following String, which consists of every ASCII punctuator except U+005F (LOW LINE): *"(){}[]|,.?\*+-^$=<>\/#&!%:;@~'"`"*.
6161
1. Let _toEscape_ be StringToCodePoints(_punctuators_).
6262
1. If _toEscape_ contains _c_ or _c_ is matched by |WhiteSpace|, then
63-
1. Append code unit U+005C (REVERSE SOLIDUS) to _codeUnits_.
63+
1. Append code point U+005C (REVERSE SOLIDUS) to _codePoints_.
6464
1. Let _hex_ be Number::toString(𝔽(_c_), 16).
6565
1. If the length of _hex_ is 1 or 2, then
6666
1. Set _hex_ to StringPad(_hex_, 2, *"0"*, ~start~).
67-
1. Append code unit U+0078 (LATIN SMALL LETTER X) to _codeUnits_.
67+
1. Append code point U+0078 (LATIN SMALL LETTER X) to _codePoints_.
68+
1. Append the code points in StringToCodePoints(_hex_) to _codePoints_.
69+
1. Else if the length of _hex_ is > 4, then
70+
1. Append code point U+007B (LEFT CURLY BRACKET) to _codePoints_.
71+
1. Append the code points in StringToCodePoints(_hex_) to _codePoints_.
72+
1. Append code point U+007D (RIGHT CURLY BRACKET) to _codePoints_.
6873
1. Else,
6974
1. Assert: The length of _hex_ is at most 4.
7075
1. Set _hex_ to StringPad(_hex_, 4, *"0"*, ~start~).
71-
1. Append code unit U+0075 (LATIN SMALL LETTER U) to _codeUnits_.
72-
1. Append the code units in _hex_ to _codeUnits_.
76+
1. Append code point U+0075 (LATIN SMALL LETTER U) to _codePoints_.
77+
1. Append the code points in StringToCodePoints(_hex_) to _codePoints_.
7378
1. Else,
74-
1. Append _c_ to _codeUnits_.
75-
1. Return _codeUnits_.
79+
1. Append _c_ to _codePoints_.
80+
1. Return _codePoints_.
7681
</emu-alg>
7782
</emu-clause>
7883
</ins>

0 commit comments

Comments
 (0)