-
Notifications
You must be signed in to change notification settings - Fork 4
/
844.txt
262 lines (188 loc) · 10.7 KB
/
844.txt
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
[1] [[Unicode]] の [DFN[[ABBR[NFC]]]] ([DFN[正規化形 C]])
は、 <http://www.unicode.org/reports/tr15/#Normalization_Form_C>
で規定されている Unicode 文字列の正規形のひとつです。
NFC は、大まかには、[[正準分解]]を行った後に[[正準結合]]を行います。
これによって、ひとつの[[文字]]に複数種類の表現が対応するときに、 ''(Unicode 的に)'' 等価でもっとも短い形にすることができます。
[17] [[Unicode]] の[[正規形]]を用いるほとんどの場面では、 [[NFC]] が採用されています。
* 仕様書
[REFS[
- [39] [[Unicode Standard]] <http://www.unicode.org/versions/latest/ch03.pdf>
]REFS]
* 定義
[2] 詳しい定義はこうです。
(実装はこれと同じ結果が得られるなら、他の方法を使ってもかまいません。)
= 原始文字列 [VAR[S]] の正準分解を、
実装が対応している最新版の [[UCD]] の[[正準写像]]に従って生成する。
= 分解中の最初から最後までのそれぞれの文字 [VAR[C]]
について、次の操作を繰り返す。
== [VAR[C]] が最後の[[開始子]] [VAR[L]] から[[妨害]]されておらず、 [VAR[L]] と[[初等結合]]できるなら、
[VAR[L]] を合成 [VAR[L-C]] で置換し、 [VAR[C]] を削除する。
= これによって得られた文字列 [VAR[S']] が [VAR[S]] の
[ABBR[NFC]] である。
[5] 仕様書:
- [UTR #15-18] [CITE[UTR #15: Unicode Normalization]]
<http://www.unicode.org/unicode/reports/tr15/tr15-18.html>
- [Cor. #2] [CITE[Corrigendum #2: Yod with Hiriq Normalization]]
<http://www.unicode.org/versions/corrigendum2.html>
* 文脈
[32] 一般論として、 [[Unicode文字列]]は [[NFC]] とするのが好ましいと考えられています。
[33] しかし、[[文字列]]の[[生成者]]は [[NFC]] を使うべきですが、
[[消費者]]は勝手に[[正規化]]するべきではないとされています。
* NFC を採用するプロトコル
[34] [[Web]] において [[NFC]] が使われる場面は、次の通りです。
[FIG(list)[
- [36] [[ドメイン]]では、
-- [[Unicode IDNA互換性処理]]で [[NFC]] が実行されます。
-- [[妥当性基準]]で [[NFC]] かどうかの検査があります。
- [37] [[XML]] では、[[著者]]の要件の一部に [[NFC]] が組み込まれています。
- [38] [[JavaScript]] の [CODE(DOMm)@en[normalize]] [[メソッド]]は、
[[NFC]] にも対応しています。
]FIG]
[35] その他色々な場面で [[NFC]] が使われることがあります。
[4]
第18版 ([[Unicode 3.0]] に対応) [SRC[UTR #15-18]] を採用する応用仕様:
- [CITE[XML Encryption Syntax and Processing]]
<http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/#sec-Processing-Encryption>
([Q['''[[MUST]]''']])
[3] 第18版 ([[Unicode 3.0]] に対応) [SRC[UTR #15-18]] と正誤表2
[SRC[Cor. #2]] を採用する応用仕様:
- [CITE[XML Encryption Syntax and Processing]]
<http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/#sec-EncryptedType>
([Q['''[[SHOULD]]''']])
[6] 最新版を採用する応用仕様:
- [CITE@en[Web Forms 2.0]]
<http://www.whatwg.org/specs/web-forms/current-work/#form-submission>
([Q@en['''[[SHOULD]]''']])
[7]
[[RFC 5335]] ([[電子メイル]][[頭部]]の[[国際化]]) は、
[[RFC 5189]] を参照しつつ、 [[NFC]] を[['''推奨''']]しています。
([[名無しさん]])
[8]
([[RFC 5335]] 4.1)
[9] [CITE[NFC FAQ (Macchiato)]] ([TIME[2009-03-02 11:37:59 +09:00]] 版) <http://www.macchiato.com/unicode/nfc-faq>
>This really depends on the kind of text involved. For example, according to data at Google:
- ~99.98% of web HTML page content characters are definitely NFC.
- Content means after discarding markup, and doing entity resolution.
- ~99.9999% of web HTML page markup characters are definitely NFC.
-- Because so much of markup is plain ASCII.
>
Of course, this represents data from just a sample of the web (in this case, the total characters in 700,000,000 documents as of January 23, 2009). Proportions may differ somewhat depending on which sample is chosen, and may change over time as the percentage of languages on the web changes. Normalization is important for some languages like Vietnamese and other languages of South and Southeast Asia even though their percentage of total text is small.
[10] [CITE[ECMAScript Language Specification (HTML version)]] ([TIME[2009-04-03 04:43:48 +09:00]] 版) <http://bclary.com/2004/11/07/#a-6>
[11] [[ES3]] は [[UTR#15]] の「1998年版」 ([[Unicode 2.1]] 世代) を[[引用]]し、
[[ソース・テキスト]]は [[NFC]] で[[正規化]]されていることが期待されているが、
[[適合ECMAScript実装]]が[[正規化]]することは[[必須]]ではない、としています [SRC[>>10]]。
;; [[必須]]ではない、ということはしてもよい、ということになります。
[12] [CITE@en[Web Applications 1.0 r7195 Revert r6810 since it doesn't work.]]
( ([TIME[2012-07-20 13:31:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7194&to=7195>
[13] [CITE@en-US[''''''[''''''DRAFT'''''']''''''Near Field Communications Working Group Charter]]
( ([TIME[2012-09-21 20:23:24 +09:00]] 版))
<http://www.w3.org/2012/05/nfc-wg-charter.html>
[14] [CITE@en[XML Encryption Syntax and Processing Version 1.1]]
( ([TIME[2013-04-13 02:02:32 +09:00]] 版))
<http://www.w3.org/TR/2013/REC-xmlenc-core1-20130411/#sec-EncryptedType>
[15] [CITE@en[XML Encryption Syntax and Processing Version 1.1]]
( ([TIME[2013-04-13 02:02:32 +09:00]] 版))
<http://www.w3.org/TR/2013/REC-xmlenc-core1-20130411/#sec-Processing-Encryption>
[16] [CITE@en[XML Signature Syntax and Processing Version 1.1]]
( ([TIME[2013-04-16 23:47:22 +09:00]] 版))
<http://www.w3.org/TR/2013/REC-xmldsig-core1-20130411/#sec-c14nAlg>
[18] [CITE@en[XSLT and XQuery Serialization 3.0]]
( ([TIME[2014-04-07 23:19:15 +09:00]] 版))
<http://www.w3.org/TR/xslt-xquery-serialization-3/#uri-escaping>
[19] [CITE@en[Character Model for the World Wide Web 1.0: Normalization]]
( ([TIME[2012-04-27 11:15:23 +09:00]] 版))
<http://www.w3.org/TR/charmod-norm/#sec-UnicodeNormalized>
[20] [CITE@en[Extensible Markup Language (XML) 1.1 (Second Edition)]]
( ([TIME[2006-09-29 19:02:09 +09:00]] 版))
<http://www.w3.org/TR/2006/REC-xml11-20060816/#sec-CharNorm>
[21] [[Charmod]] で[DFN[[RUBYB[[[Unicode正規化済み]]]@en[Unicode-normalized]]]]とは [[NFC]]
のことをいいます [SRC[>>19, >>20]]。 [[NFC]] と[[マーク付け言語]]の構造の組み合わせにより[[取り込み正規化済み]]、
[[完全正規化済み]]という正規化の形が定義されています。 [[XML 1.0]] と [[XML 1.1]]
は[[構文解析対象実体]]が[[完全正規化済み]]である[['''べき''']]としています。
[22] [CITE@en[RFC 5335 - Internationalized Email Headers]]
( ([TIME[2014-03-09 12:10:16 +09:00]] 版))
<http://tools.ietf.org/html/rfc5335#section-4.1>
[23] [CITE@en[RFC 6532 - Internationalized Email Headers]]
( ([TIME[2014-03-09 10:33:13 +09:00]] 版))
<http://tools.ietf.org/html/rfc6532#section-3.1>
[24] [[RFC 6570]] [[URI Template]] は [[Unicode 6.0.0]] [[NFC]] を採用しています。
[25] [[RFC 5198]] [[Net-Unicode]]
[26] [CITE@en[RFC 7542 - The Network Access Identifier]]
([TIME[2015-05-02 05:20:57 +09:00]] 版)
<https://tools.ietf.org/html/rfc7542#section-2.1>
[27] [[基本認証]]の [CODE(HTTP)@en[[[charset=""]]]] の値 [CODE(charset)@en[[[UTF-8]]]]
[FIG(quote)[
[FIGCAPTION[
[28] [CITE@en[RFC 7542 - The Network Access Identifier]]
([TIME[2015-10-18 15:17:56 +09:00]] 版)
<https://tools.ietf.org/html/rfc7542#section-2.1>
]FIGCAPTION]
> Strings that are not Normal Form Composed (NFC)
> are not valid NAIs and SHOULD NOT be treated as such.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[29] [CITE[Open Publication Structure (OPS) 2.0.1 v1.0]]
([TIME[2015-09-08 04:50:12 +09:00]] 版)
<http://www.idpf.org/epub/20/spec/OPS_2.0_latest.htm#Section1.3.6>
]FIGCAPTION]
> To aid Reading Systems in implementing consistent searching and sorting behavior it is required that Unicode Normalization Form C (NFC) be used
]FIG]
[FIG(quote)[
[FIGCAPTION[
[30] [CITE@en[Model for Tabular Data and Metadata on the Web]]
([TIME[2015-12-03 19:28:42 +09:00]] 版)
<http://www.w3.org/TR/2015/REC-tabular-data-model-20151217/#encoding>
]FIGCAPTION]
> CSV files should be encoded using UTF-8, and should be in Unicode Normal Form C as defined in '''['''UAX15''']'''.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[31] [CITE@en[RFC 7564 - PRECIS Framework: Preparation, Enforcement, and Comparison of Internationalized Strings in Application Protocols]]
([TIME[2015-12-21 04:49:41 +09:00]] 版)
<https://tools.ietf.org/html/rfc7564#section-5.2.4>
]FIGCAPTION]
> In accordance with '''['''RFC5198''']''', normalization form C (NFC) is
> RECOMMENDED.
]FIG]
[40] [CITE@en[XSLT and XQuery Serialization 3.1]]
([TIME[2017-03-20 12:35:18 +09:00]])
<https://www.w3.org/TR/2017/REC-xslt-xquery-serialization-31-20170321/#uri-escaping>
[41] [CITE@en[159891 – '''['''encoding''']''' Support for GB18030]]
([TIME[2017-05-12 11:23:12 +09:00]])
<https://bugs.webkit.org/show_bug.cgi?id=159891>
[42] [CITE[XLIFF Version 2.0]]
([TIME[2014-08-06 01:00:00 +09:00]])
<http://docs.oasis-open.org/xliff/xliff-core/v2.0/os/xliff-core-v2.0-os.html#slr_storage>
[FIG(quote)[
[FIGCAPTION[
[43] [CITE@en[Dropbox - Core API - endpoint reference]]
([TIME[2017-05-26 00:23:53 +09:00]])
<https://www.dropbox.com/developers-v1/core/docs>
]FIGCAPTION]
> Every string passed to and from the Dropbox API needs to be UTF-8 encoded. For maximum compatibility, normalize to Unicode Normalization Form C (NFC) before UTF-8 encoding.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[44] [CITE@en[RFC 8162 - Using Secure DNS to Associate Certificates with Domain Names for S/MIME]]
([TIME[2017-06-01 08:15:21 +09:00]])
<https://tools.ietf.org/html/rfc8162#section-3>
]FIGCAPTION]
> If the local-part contains any non-ASCII characters, it SHOULD be
> normalized using the Unicode Normalization Form C from '''['''UNICODE''']'''.
> Recommended normalization rules can be found in Section 10.1 of
> '''['''RFC6530''']'''.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[45] [CITE@en-us[UTS #22: CharMapML]]
([TIME[2017-06-01 07:35:01 +09:00]])
<http://www.unicode.org/reports/tr22/tr22-8.html#att_u>
]FIGCAPTION]
> Where possible, this should be in Normalization Form C.
]FIG]
[46] [CITE@en[RFC 5280 - Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile]]
([TIME[2018-08-26 16:15:03 +09:00]])
<https://tools.ietf.org/html/rfc5280#section-4.2.1.4>
[47] [CODE[rdf:XMLLiteral]]