This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
spec.emu
124 lines (122 loc) · 3.83 KB
/
spec.emu
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!doctype html>
<meta charset="utf8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<pre class="metadata">
title: Well-formed JSON.stringify
status: proposal
stage: 4
shortname: <a href="https://github.com/gibson042/ecma262-proposal-well-formed-stringify">proposal-well-formed-stringify</a>
contributors: Richard Gibson
</pre>
<emu-biblio href="./missing-productions.json"></emu-biblio>
<emu-clause id="sec-quotejsonstring" aoid="QuoteJSONString">
<h1>Runtime Semantics: QuoteJSONString ( _value_ )</h1>
<p>The abstract operation QuoteJSONString with argument _value_ wraps a String value in QUOTATION MARK code units and escapes certain other code units within it.</p>
<emu-alg>
1. Let _product_ be the String value consisting solely of the code unit 0x0022 (QUOTATION MARK).
1. For each code <del>unit</del><ins>point</ins> _C_ in _value_ <ins>when interpreted as UTF-16 encoded Unicode text as described in <emu-xref href="#sec-ecmascript-language-types-string-type"></emu-xref></ins>, do
1. If <del>the numeric value of</del> _C_ is listed in the Code <del>Unit Value</del><ins>Point</ins> column of <emu-xref href="#table-json-single-character-escapes"></emu-xref>, then
1. Set _product_ to the string-concatenation of _product_ and the Escape Sequence for _C_ as specified in <emu-xref href="#table-json-single-character-escapes"></emu-xref>.
1. Else if _C_ has a numeric value less than 0x0020 (SPACE), <ins>or _C_ has the same numeric value as a <emu-xref href="#leading-surrogate-code-unit"></emu-xref> or <emu-xref href="#trailing-surrogate-code-unit"></emu-xref>,</ins> then
1. <ins>Let _unit_ be a code unit whose numeric value is that of _C_.</ins>
1. Set _product_ to the string-concatenation of _product_ and UnicodeEscape(_unit_).
1. Else,
1. Set _product_ to the string-concatenation of _product_ and <ins>the <emu-xref aoid="UTF16Encoding"></emu-xref> of</ins> _C_.
1. Set _product_ to the string-concatenation of _product_ and the code unit 0x0022 (QUOTATION MARK).
1. Return _product_.
</emu-alg>
<emu-table id="table-json-single-character-escapes" caption="JSON Single Character Escape Sequences">
<table>
<tbody>
<tr>
<th>
Code <del>Unit Value</del><ins>Point</ins>
</th>
<th>
Unicode Character Name
</th>
<th>
Escape Sequence
</th>
</tr>
<tr>
<td>
<del>`0x0008`</del><ins>U+0008</ins>
</td>
<td>
BACKSPACE
</td>
<td>
`\\b`
</td>
</tr>
<tr>
<td>
<del>`0x0009`</del><ins>U+0009</ins>
</td>
<td>
CHARACTER TABULATION
</td>
<td>
`\\t`
</td>
</tr>
<tr>
<td>
<del>`0x000A`</del><ins>U+000A</ins>
</td>
<td>
LINE FEED (LF)
</td>
<td>
`\\n`
</td>
</tr>
<tr>
<td>
<del>`0x000C`</del><ins>U+000C</ins>
</td>
<td>
FORM FEED (FF)
</td>
<td>
`\\f`
</td>
</tr>
<tr>
<td>
<del>`0x000D`</del><ins>U+000D</ins>
</td>
<td>
CARRIAGE RETURN (CR)
</td>
<td>
`\\r`
</td>
</tr>
<tr>
<td>
<del>`0x0022`</del><ins>U+0022</ins>
</td>
<td>
QUOTATION MARK
</td>
<td>
`\\"`
</td>
</tr>
<tr>
<td>
<del>`0x005C`</del><ins>U+005C</ins>
</td>
<td>
REVERSE SOLIDUS
</td>
<td>
`\\\\`
</td>
</tr>
</tbody>
</table>
</emu-table>
</emu-clause>