-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathindex.html
2189 lines (1835 loc) · 169 KB
/
index.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
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="UTF-8">
<!--
Editor's note: the current list of Unicode characters used in this document is:
U+0130 U+0131 U+0133 U+0141 U+017E U+01C4 U+01C5 U+01C6 U+01FA U+0300 U+0301 U+0307 U+030A U+0323 U+0327 U+0342 U+0398 U+03A1 U+03A9 U+03B1 U+03B8 U+03B9 U+03C9 U+0414 U+0420 U+0434 U+0627 U+0628 U+062A U+0646 U+0647 U+0654 U+08A1 U+0915 U+0921 U+0928 U+092F U+093F U+0942 U+094B U+1100 U+1161 U+1780 U+178A U+178F U+17D2 U+1E9E U+1F23 U+1F7C U+1F93 U+1F9B U+1FB6 U+1FB7 U+1FF2 U+200B U+200C U+200D U+2014 U+2019 U+2044 U+2079 U+2089 U+208A U+20AC U+210C U+210D U+2126 U+212B U+215F U+2189 U+21D2 U+2260 U+2460 U+2469 U+2474 U+2488 U+24B6 U+25CC U+2EF3 U+3002 U+30A2 U+30AB U+30C8 U+30D1 U+30E6 U+30F3 U+30FC U+3250 U+329E U+3300 U+3350 U+3389 U+3392 U+5370 U+9F9F U+AC00 U+1F1F2 U+1F1FF U+1F3F4 U+1F3FB U+1F3FC U+1F3FD U+1F3FE U+1F3FF U+1F467 U+1F468 U+1F469 U+1F46A U+E0062 U+E0063 U+E0067 U+E0073 U+E0074 U+E007F U+FE37 U+FEE9 U+FEEA U+FEEB U+FEEC U+FF21 U+FF5B U+FF76
-->
<title>Character Model for the World Wide Web: String Matching</title>
<link rel="canonical" href="https://www.w3.org/TR/charmod-norm/"/>
<!-- local styles. Includes the styles from http://www.w3.org/International/docs/styleguide -->
<link rel="stylesheet" href="local.css">
<script src="https://www.w3.org/Tools/respec/respec-w3c" async class="remove"></script>
<script class="remove">
var respecConfig = {
// specification status (e.g. WD, LCWD, NOTE, etc.). If in doubt use ED.
specStatus: "ED",
//publishDate: "2019-02-04",
//previousPublishDate: "2019-02-04",
//previousMaturity: "WG-NOTE",
noRecTrack: true,
shortName: "charmod-norm",
copyrightStart: "2004",
edDraftURI: "https://w3c.github.io/charmod-norm/",
// lcEnd: "2009-08-05",
// editors, add as many as you like
// only "name" is required
editors: [
{ name: "Addison Phillips",
company: "Amazon.com",
w3cid: 33573 },
],
// authors, add as many as you like.
//authors: [
// { name: "Your Name", url: "http://example.org/",
// company: "Your Company", companyURL: "http://example.com/" },
//],
group: "i18n",
github: "w3c/charmod-norm",
localBiblio: {
"UTS18": {
title: "Unicode Technical Standard #18: Unicode Regular Expressions",
href: "https://unicode.org/reports/tr18/",
authors: [ "Mark Davis", "Andy Heninger" ]
},
"Encoding": {
title: "Encoding",
href: "https://www.w3.org/TR/encoding/",
authors: [ "Anne van Kesteren", "Joshua Bell", "Addison Phillips" ]
},
"ISO10646": {
title: "Information Technology - Universal Multiple- Octet Coded CharacterSet (UCS) - Part 1: Architecture and Basic Multilingual Plane",
authors: [ "ISO/IEC10646-1:1993" ],
note: "The current specification also takes into consideration the first five amendments to ISO/IEC 10646-1:1993. Useful roadmaps (http://www.egt.ie/standards/iso10646/ucs-roadmap.html) show which scripts sit at which numeric ranges."
},
"UTS10": {
title: "Unicode Technical Standard #10: Unicode Collation Algorithm",
href: "https://www.unicode.org/reports/tr10/",
authors: [ "Mark Davis", "Ken Whistler", "Markus Scherer" ]
},
"UAX9": {
title: "Unicode Standard Annex #9: Unicode Bidirectional Algorithm",
href: "https://unicode.org/reports/tr9/",
authors: [ "Mark Davis", "Aharon Lahnin", "Andrew Glass" ]
},
"UAX11": {
title: "Unicode Standard Annex #11: East Asian Width",
href: "https://www.unicode.org/reports/tr11/",
authors: [ "Ken Lunde 小林劍" ]
},
"UAX29": {
title: "Unicode Standard Annex #29: Unicode Text Segmentation",
href: "https://www.unicode.org/reports/tr29/",
authors: [ "Mark Davis" ]
},
"UTS39": {
title: "Unicode Technical Standard #39: Unicode Security Mechanisms",
href: "https://www.unicode.org/reports/tr39/",
authors: [ "Mark Davis", "Michel Suignard" ]
},
"UTR36": {
title: "Unicode Technical Report #36: Unicode Security Considerations",
href: "https://www.unicode.org/reports/tr36/",
authors: [ "Mark Davis", "Michel Suignard" ]
},
"UTR50": {
title: "Unicode Technical Report #50: Unicode Vertical Text Layout",
href: "https://www.unicode.org/reports/tr50/",
authors: [ "Koji Ishii 石井宏治" ]
},
"UTR51": {
title: "Unicode Technical Report #51: Unicode Emoji",
href: "https://www.unicode.org/reports/tr51/",
authors: [ "Mark Davis", "Peter Edberg" ]
},
"STRING-SEARCH": {
title: "Character Model for the World Wide Web: String Searching",
href: "https://w3c.github.io/string-search/",
authors: [ "Addison Phillips" ]
},
"ASCII": {
title: "ISO/IEC 646:1991, Information technology -- ISO 7-bit coded character set for information interchange",
href: "http://www.ecma-international.org/publications/standards/Ecma-006.htm",
isoNumber: "ISO/IEC 646:1991",
note: "This standard defines an International Reference Version (IRV) which corresponds exactly to what is widely known as ASCII or US-ASCII. ISO/IEC 646 was based on the earlier standard ECMA-6. ECMA has maintained its standard up to date with respect to ISO/IEC 646 and makes an electronic copy available at http://www.ecma-international.org/publications/standards/Ecma-006.htm "
},
}
};
</script>
</head>
<body>
<div id="abstract">
<p>This document builds upon <cite>Character Model for the World Wide Web 1.0: Fundamentals </cite>[[CHARMOD]] to provide authors of specifications, software developers, and content developers a common reference on string identity matching on the World Wide Web and thereby increase interoperability.</p>
</div>
<div id="sotd">
<p>To make it easier to track comments, please raise separate issues or emails for each comment, and point to the section you are commenting on using a URL.</p>
</div>
<section id="intro">
<h2>Introduction</h2>
<section id="goals">
<h3>Goals and Scope</h3>
<p>The goal of the Character Model for the World Wide Web is to facilitate use of the Web by all people, regardless of their language, script, writing system, or cultural conventions, in accordance with the <a href="http://www.w3.org/Consortium/mission"><cite>W3C goal of universal access</cite></a>. One basic prerequisite to achieve this goal is to be able to transmit and process the characters used around the world in a well-defined and well-understood way.</p>
<p class="note">This document builds on <cite>Character Model for the World Wide Web: Fundamentals</cite> [[CHARMOD]]. Understanding the concepts in that document are important to being able to understand and apply this document successfully.</p>
<p>This part of the Character Model for the World Wide Web covers string
matching—the process by which a specification or implementation defines
whether two string values are the same or different from one another. It
describes the ways in which texts that are semantically equivalent can
be encoded differently and the impact this has on matching operations
important to formal languages (such as those used in the formats and
protocols that make up the Web).</p>
<p>The main target audience of this specification is W3C specification
developers. This specification and parts of it can be referenced from
other W3C specifications and it defines conformance criteria for W3C
specifications, as well as other specifications.</p>
<p>Other audiences of this specification include software developers,
content developers, and authors of specifications outside the W3C.
Software developers and content developers implement and use W3C
specifications. This specification defines some conformance criteria
for implementations (software) and content that implement and use W3C
specifications. It also helps software developers and content
developers to understand the character-related provisions in W3C
specifications.</p>
<p>The character model described in this specification provides authors
of specifications, software developers, and content developers with a
common reference for consistent, interoperable text manipulation on
the World Wide Web. Working together, these three groups can build a
globally accessible Web.</p>
</section>
<section id="structure">
<h3>Structure of this Document</h3>
<p>This document defines one of the basic building blocks for the Web related
to this problem by defining rules and processes for String
Identity Matching in document formats. These rules are designed for
the identifiers and structural markup (<a href="#def_syntactic_content" class="termref">syntactic content</a>)
used in document formats to ensure consistent processing of each and are
targeted to Specification writers. This
section is targeted to implementers.</p>
<p>This document is divided into two main sections.</p>
<p>The <a href="#problemStatement">first section</a> lays out the
problems involved in string matching; the effects of Unicode and case
folding on these problems; and outlines the various issues and
normalization mechanisms that might be used to address these issues.</p>
<p>The <a href="#identityMatching">second section</a> provides
requirements and recommendations for string identity matching for use
in <span class="qterm">formal languages</span>, such as many of the
document formats defined in W3C Specifications. This primarily is
concerned with making the Web functional and providing document
authors with consistent results. </p>
</section>
<section id="background">
<h3>Background</h3>
<p>This section provides some historical background on the topics
addressed in this specification.</p>
<p>At the core of the character model is the Universal Character Set
(UCS), defined jointly by the <cite>Unicode Standard</cite>
[[!Unicode]] and ISO/IEC 10646 [[!ISO10646]]. In this document, <dfn>Unicode</dfn>
is used as a synonym for the Universal Character Set. A successful
character model allows Web documents authored in the world's writing
systems, scripts, and languages (and on different platforms) to be
exchanged, read, and searched by the Web's users around the world.</p>
<p>The first few chapters of the <cite>Unicode Standard</cite>
[[!Unicode]] provide useful background reading.</p>
<p>For information about the requirements that informed the development
of important parts of this specification, see <cite>Requirements for
String Identity Matching and String Indexing</cite> [[CHARREQ]].</p>
</section>
<section id="terminology">
<h3>Terminology and Notation</h3>
<p>This section contains terminology and notation specific to this document.</p>
<p>The Web is built on text-based formats and protocols. In order to
describe string matching or searching effectively, it is necessary to
establish terminology that allows us to talk about the different kinds
of text within a given format or protocol, as the requirements and
details vary significantly. </p>
<p>A <dfn data-lt="Unicode code point|Unicode code points|code point|code points">Unicode code point</dfn> (or "code point") refers to the numeric value assigned to each Unicode character. Unicode code points range from <code class="kw" translate="no">0</code> to <code class="kw" translate="no">0x10FFFF</code>. (See Section 4.1 in [[!CHARMOD]] for a deeper discussion of character encoding terminology.)</p>
<p>Unicode code points are denoted as <code class="kw" translate="no">U+<em>hhhh</em></code>, where <code class="kw" translate="no"><em>hhhh</em></code> is a sequence of at least four, and at most six hexadecimal digits. For example, the character <span class="codepoint"><span lang="en">€</span> [<span class="uname">U+20AC EURO SIGN</span>]</span> has the code point <span class="uname" translate="no">U+20AC</span>, while the character <span class="codepoint">😺</span> [<span class="uname">U+1F63A SMILING CAT FACE WITH OPEN MOUTH</span>] has the code point <span class="uname" translate="no">U+1F63A</span>.</p>
<p>Some characters used in this document's examples might not appear as intended on your specific device or display. Usually this is due to lack of a script-specific font installed locally or due to other limitations of your specific rendering system. This document uses a Webfont to provide fallback glyphs for many of the non-Latin characters, but your device might not support displaying the font. To the degree possible, the editors have tried to ensure that the examples nevertheless remain understandable.</p>
<p>A <dfn data-lt="legacy character encoding|legacy character encodings">legacy character encoding</dfn> is a character encoding form that does not encode the full repertoire of characters in the Unicode character set.</p>
<p>A <dfn data-lt="transcoder|transcoders">transcoder</dfn> is a process that converts
text between two character encodings. Most commonly in this document it
refers to a process that converts from a <a>legacy character encoding</a>
to a <a href="http://www.w3.org/TR/2005/REC-charmod-20050215/#Unicode_Encoding_Form">Unicode encoding form</a>,
such as UTF-8.</p>
<p><dfn data-lt="natural language">Natural language</dfn> is the spoken, written, or signed communications used by human beings (see also <a href="https://www.w3.org/TR/ltli/#dfn-natural-language">here</a> [[LTLI]])</p>
<p><dfn data-lt="syntactic content" id="def_syntactic_content">Syntactic content</dfn> is any text in a document format or protocol that belongs to the structure of the format or protocol. This definition includes values that are typically thought of as "markup" but can also include other values, such as the name of a field in an HTTP header. Syntactic content consists of all of the characters that form the <em>structure</em> of a format or protocol. For example, <span class="qchar"><</span> and <span class="qchar">></span> (as well as the element name and various attributes they surround) are part of the syntactic content in an HTML document.</p>
<p>Syntactic content usually is defined by a specification or specifications and includes both the defined, reserved keywords for the given protocol or format as well as string tokens and identifiers that are defined by document authors to form the structure of the document (rather than the "content" of the document).</p>
<p>A <dfn id="def_vocabulary">vocabulary</dfn> is the list of reserved keywords and/or rules for assigning <a>user-supplied values</a> (such as identifiers) in a format or protocol. This can include restrictions on range, order, or type of characters that can appear in different places.</p>
<p>For example, HTML defines the names of its elements and attributes, as well as enumerated attribute values, which defines the "vocabulary" of HTML <a>syntactic content</a>. Another example would be ECMAScript, which restricts the range of characters that can appear at the start or in the body of an identifier or variable name. It applies different rules for other cases, such as to the values of string literals.</p>
<p>Values within a <a>vocabulary</a> fall into two broad classes: those that are meant to be seen, read, or interacted with by humans (and thus might be expected to contain natural language text); and those that are application or protocol internal and not intended for human interaction.</p>
<p>A <dfn>user-facing identifier</dfn> is an identifier defined by or assigned by a user in a <a>vocabulary</a> that is intended to be at least potentially visible to end-users (and thus is <a>localizable content</a>).</p>
<p>An <dfn>application internal identifier</dfn> is an identifier defined by or assigned by a user in a <a>vocabulary</a> that is internal to the document format or protocol and not intended for human interaction. Such values are generally not <a>localizable content</a>.</p>
<p>A <dfn data-lt="user-supplied value|user-supplied values">user-supplied value</dfn> is unreserved <a>syntactic content</a> in a <a>vocabulary</a> that is assigned by users, as distinct from reserved keywords in a given format or protocol. Users generally expect that their user-supplied values can be words or phrases in their preferred <a>natural language</a>. This is why [[CHARMOD]] recommends that "Specifications SHOULD NOT arbitrarily exclude code points from the full range of Unicode code points from <code>U+0000</code> to <code>U+10FFFF</code> inclusive."</p>
<aside class="example">
<p>CSS defines the syntax of a style sheet and reserves a number of keywords, such as <code>margin-left</code> or <code>font-family</code>, or values such as <code>10px</code>. All of these definitions are part of the <a>syntactic content</a> of a CSS style sheet. CSS also allows users to define certain values such as class names using a wide range of Unicode characters. These <a>user-supplied values</a> are also part of the <a>syntactic content</a> of the style sheet where they appear.</p>
</aside>
<aside class="example">
<p><cite>XML</cite> [[XML10]] defines specific elements, attributes, and values that are reserved across all XML documents. Thus, the word <code class="kw" translate="no">encoding</code> has a defined meaning inside the XML document declaration: it is a reserved name. XML also allows a user to define elements and attributes for a given document, for example, by using a DTD. In a document that uses a DTD that defines an element called <code class="kw"><muffin></code>, <span class="qterm">muffin</span> is a part of the syntactic content.</p>
</aside>
<p><dfn>Localizable content</dfn> refers to document contents intended as human-readable text and <b>not</b> to any of the surrounding or embedded syntactic content that form part of the document structure. Note that syntactic content can have localizable content embedded in it, such as when an [[HTML]] <code class="kw">img</code> element has an <code class="kw">alt</code> attribute containing a description of the image.</p>
<aside class="example">
<p>Here is an example (similar to the one found in [[STRING-META]]) of a JSON document containing a mixture of syntactic and localizable content. The values whose key is <code>value</code> (in the fields <code>title</code>, <code>author</code>, and <code>publisher</code>) are localizable content. Notice that they are associated with language and base direction metadata.</p>
<p>The keys (<code>isbn</code>, <code>bookLanguage</code>, <code>title</code> etc.) are application internal identifiers in this document's vocabulary. Values such as the publication date (<code>2008-01-01</code>) are user-supplied values.</p>
<!--
Title below is "HTML and CSS: Design and Build Websites"
ASIN: 1118871642
ISBN-13: 978-1118871645
ISBN-10: 1118871642
-->
<p id="example1Data" style="white-space:pre;font-family:monospace">
{
// syntactic content and user-values
"isbn": "978-111887164-5",
"bookLanguage": "ar",
"pubDate": "2008-01-01",
"downloadLocation": "https://example.com/books/978-111887164-5",
"isTranslated": true,
"updateDate": "2021-04-31T19:23:14Z",
// localizable content
"title": {
"value": "<span dir=rtl>HTML و CSS: تصميم و إنشاء مواقع الويب</span>",
"lang": "ar-AE",
"dir": "rtl"
},
"author": {
"value": "Jon Duckett",
"lang": "en",
"dir": "ltr"
},
"publisher": {
"value": "مكتبة",
"lang": "ar",
"dir": "rtl"
},
},
</p>
</aside>
<p>A <dfn data-lt="resource|resources">resource</dfn>, in the context of this document, is a given document, file, or protocol "message" which includes both the <a>localizable content</a> as well as the <a>syntactic content</a> such as identifiers surrounding or containing it. For example, in an HTML document that also has some CSS and a few <code class="kw" translate="no">script</code> tags with embedded JavaScript, the entire HTML document, considered as a file, is a resource. This term is intentionally similar to the term 'resource' as used in [[RFC3986]], although here the term is applied loosely. </p>
<p>A <dfn data-lt="grapheme|graphemes">grapheme</dfn> is a sequence of
one or more characters in a visual representation of some text
that a typical user would perceive as being a single unit (<q>character</q>).
Graphemes are important for a number of text operations such as
sorting or text selection, so it is necessary to be able to compute
the boundaries between each user-perceived character. Unicode defines
the default mechanism for computing graphemes in <cite>Unicode
Standard Annex #29: Text Segmentation</cite> [[!UAX29]] and calls
this approximation a <dfn>grapheme cluster</dfn>. There are two types
of default grapheme cluster defined. Unless otherwise noted, grapheme
cluster in this document refers to an extended default grapheme
cluster. (A discussion of grapheme clusters is also given in Section 2
of the <cite>Unicode Standard</cite>, [[!Unicode]]. Cf. near the end of
<a href="http://www.unicode.org/versions/latest/ch02.pdf">Section 2.11</a>
in version 8.0 of The Unicode Standard)</p>
<p>Because different natural languages have different needs, grapheme clusters
can also sometimes require tailoring. For example, a Slovak user might
wish to treat the default pair of grapheme clusters "ch" as a single
grapheme cluster. Note that the interaction between the language of
string content and the end-user's preferences might be complex.</p>
<aside class="example" id=graphemeExample>
<p>The Hindi word for Unicode <q>यूनिकोड</q> is composed of seven Unicode characters from the Devanagari script.
</p>
<p>Most users would identify this word as containing four units of text. Each of the first three graphemes consists of two characters: a syllable and a modifying vowel character. So the word contains seven Unicode characters, but only four graphemes:</p>
<table style="width: 70%; margin-left: 15%; margin-right: 15%">
<tr>
<td style="width: 30%">Word</td>
<td colspan=7 class="bigtext">यूनिकोड</td>
</tr>
<tr>
<td>Graphemes</td>
<td class="bigtext" colspan=2>यू</td>
<td class="bigtext" colspan=2>नि</td>
<td class="bigtext" colspan=2>को</td>
<td class="bigtext">ड</td>
</tr>
<tr>
<td>Code Points</td>
<td class="bigtext">य</td>
<td class="bigtext">ू</td>
<td class="bigtext">न</td>
<td class="bigtext">ि</td>
<td class="bigtext">क</td>
<td class="bigtext">ो</td>
<td class="bigtext">ड</td>
</tr>
<tr>
<td></td>
<td style="text-align:center">U+092F</td>
<td style="text-align:center">U+0942</td>
<td style="text-align:center">U+0928</td>
<td style="text-align:center">U+093F</td>
<td style="text-align:center">U+0915</td>
<td style="text-align:center">U+094B</td>
<td style="text-align:center">U+0921</td>
</tr>
</table>
</aside>
<section>
<h5>Terminology Examples</h5>
<p>This section illustrates some of the terminology defined above. For illustration purposes we'll use the following small HTML file as an example (line numbers added for reference):</p>
<div class=terminologyExample>
<p class=syntaxExample><span class=lnum>1 </span> <span class="markup"><<span class="vocabulary">html</span> <span class="vocabulary">lang</span>="<span class=userValue>en</span>" <span class="vocabulary">dir</span>="<span class="vocabulary">ltr</span>"></span></p>
<p class=syntaxExample><span class=lnum>2 </span><span class="markup"><<span class="vocabulary">head</span>></span></p>
<p class=syntaxExample><span class=lnum>3 </span><span class="markup"> <<span class="vocabulary">meta</span> <span class="vocabulary">charset</span>="<span class=userValue>UTF-8</span>"></span></p>
<p class=syntaxExample><span class=lnum>4 </span><span class=markup> <<span class="vocabulary">title</span>></span><span class="shakespeare">Shakespeare</span><span class="markup"></<span class="vocabulary">title</span>></span></p>
<p class=syntaxExample><span class=lnum>5 </span></<span class="vocabulary">head</span>></p>
<p class=syntaxExample><span class=lnum>6 </span><<span class="vocabulary">body</span>></p>
<p class=syntaxExample><span class=lnum>7 </span><span class=markup> <<span class="vocabulary">img</span> <span class="vocabulary">src</span>="<span class="userValue">shakespeare.jpg</span>" <span class="vocabulary">alt</span>="<span class="userValue"><span class="shakespeare">William Shakespeare</span></span>" <span class="vocabulary">id</span>="<span class="userValue">shakespeare_image</span>"></span></p>
<p class=syntaxExample><span class=lnum>8 </span><span class=markup> <<span class="vocabulary">p</span>></span><span class="shakespeare">What<span class="markup">&#x2019;</span>s in a name? That which we call a rose by any other name would smell as sweet.</span><span class="markup"></<span class="vocabulary">p</span>></span></p>
<p class=syntaxExample><span class=lnum>9 </span></<span class="vocabulary">body</span>></p>
<p class=syntaxExample><span class=lnum>10 </span><span class=markup></<span class="vocabulary">html</span>></span> </p>
</div>
<ul style="text-align:left">
<li>Everything inside the black rectangle (that is, in this HTML file) is part of the <a>resource</a>.</li>
<li><a>Syntactic content</a> in this case includes all of the HTML markup. There are only two strings that are <strong>not</strong> part of the syntactic content: the word <em>"Shakespeare"</em> on line 4 and the sentence <em>"What’s in a name? That which we call a rose by any other name would smell as sweet."</em> on line 8. (The HTML entity <q><kbd>&#x2019;</kbd></q> embedded in the sentence on line 8 <em>is</em> part of the syntactic content.)</li>
<li><a>Localizable content</a> is shown in a <span class="shakespeare">bold blue font with a gray background</span>. In addition to the non-syntactic content, the <kbd>alt</kbd> value on line 7 (<em><q>William Shakespeare</q></em>) is localizable content.</li>
<li>User-supplied values are shown in <span class="userValue">italics</span>. In this case there are three user-supplied values on line 7: the values of the <kbd>src</kbd>, <kbd>alt</kbd>, and <kbd>id</kbd> attributes of the <kbd>img</kbd> tag. In addition, the value of the <kbd>lang</kbd> attribute on line 1 and the <kbd>charset</kbd> attribute on line 3 are user-supplied values.</li>
<li><a>Vocabulary</a> is shown with <span class="vocabulary">red underlining</span>. The vocabulary of an HTML document are the elements and attributes (as well as some of the attribute values, such as the value <kbd>ltr</kbd> for the attribute <kbd>dir</kbd> in the example above) defined in [[HTML]].</li>
</ul>
<p class=note>All of the text above (all text in a text file) makes up the resource. It's possible that a given resource will contain no <a>localizable content</a> at all (consider an HTML document consisting of four empty <code>div</code> elements styled to be orange rectangles). It's also possible that a resource will contain <em>no</em> syntactic content and consist solely of <a>localizable content</a>: for example, a plain text file with a soliloquy from <cite>Hamlet</cite> in it. Notice too that the HTML entity <code>&#x2019;</code>appears in the localizable content and belongs to both the localizable content and the syntactic content in this resource.</p>
</section>
</section>
<section id="conformance">
<p>This document describes best practices for the authors of other specifications, as well as recommendations for implementations and content authors. These best practices can also be found in the Internationalization Working Group's document <cite>Internationalization Best Practices for Spec Developers</cite> [[!INTERNATIONAL-SPECS]], which is intended to serve as a general reference for all Internationalization best practices in W3C specifications.</p>
<!--p class="advisement" id="charmod_consistent_format"><a class="self" href="#charmod_consistent_format">[C] </a>When a best practice or recommendation appears in this document, it has been styled like this paragraph. Recommendations for specifications and spec authors are labelled [S]. Recommendations for implementations and software developers are labelled [I]. Recommendations for content and content authors are labelled [C].</p-->
<p>Best practices in this document use [[!RFC2119]] keywords in order to clarify the Internationalization Working Group's intentions regarding a specific recommendation. Following the recommendations in this document can help avoid issues during the W3C's "wide review" process, during implementation, or in the content that authors produce. This document is not, itself, normative and can be revised from time to time.</p>
<p>Specifications can claim conformance to this document if they:</p>
<ol type="1">
<li>do not violate any conformance criteria preceded by <span class=qrec>[S]</span> where the imperative is MUST or MUST NOT</li>
<li>document the reason for any deviation from criteria where the imperative is SHOULD, SHOULD NOT, or RECOMMENDED</li>
<li>make it a conformance requirement for implementations to conform to this document</li>
<li>make it a conformance requirement for content to conform to this document</li>
</ol>
<p class=note>Requirements placed on specifications might indirectly cause requirements to be placed on implementations or content that claim to conform to those specifications.</p>
<p>Where this specification contains a procedural description, it is to be understood as a way to specify the desired external behavior. Implementations MAY use other means of achieving the same results, as long as observable behavior is not affected.</p>
</section>
</section>
<section id="problemStatement">
<h2>The String Matching Problem</h2>
<p>The Web is primarily made up of document formats and protocols based on
character data. These formats or protocols can be viewed as a set of <a>resources</a> consisting mainly of text files that include some form of structural markup or <a>syntactic content</a>. Processing such syntactic content or document data requires
string-based operations such as matching (including regular expressions), indexing, searching, sorting,
and so forth.</p>
<p>Users, particularly implementers, sometimes have naïve expectations regarding the matching or non-matching
of similar strings or of the efficacy of different transformations they might apply to text, particularly to
syntactic content, but including many types of text processing on the Web.</p>
<p>Because fundamentally the Web is sensitive to the different ways in which text might be represented in a
document, failing to consider the different ways in which the same text can be represented can confuse
users or cause unexpected or frustrating results. In the sections below, this document examines the different
types of text variation that affect both user perception of text on the Web and the string processing on which
the Web relies.</p>
<section id="definitionCaseFolding">
<h3>Case Mapping and Case Folding</h3>
<p>Some scripts and writing systems make a distinction between UPPER, lower, and Title case characters. Most scripts, including the Brahmic scripts of India, the Arabic script, and the scripts used to write Chinese, Japanese, or Korean, do not have a case distinction, but some important ones do. Examples of such scripts include the Latin script used in the majority of this document, as well as scripts such as Greek, Armenian, and Cyrillic. </p>
<p><dfn>Case mapping</dfn> is the process of transforming characters to a specific case, such as UPPER, lower, or Titlecase. For those scripts that have a case distinction, Unicode defines a <em>default</em> UPPER, lower, and Titlecase character mapping for each Unicode code point. Case mapping, at first, appears simple. However there are variations that need to be considered when treating the full range of Unicode in diverse languages.</p>
<aside class="note">
<p>For more information, see [[!Unicode]] <a href="http://www.unicode.org/versions/latest/ch05.pdf">Chapter 5</a> in the section titled <em>Case Mappings</em>) for a detailed discussion of case mapping and case folding. </p>
</aside>
<aside class="example">
<p>For example here is a character with mappings to all three case variations. These mappings are defined in the <a href="http://www.unicode.org/Public/UCD/latest/ucd/">Unicode Character Database</a> (UCD).</p>
<table>
<tr>
<th>Uppercase</th>
<th>Lowercase</th>
<th>Titlecase</th>
</tr>
<tr>
<td class="exampleChar">DŽ</td>
<td class="exampleChar">dž</td>
<td class="exampleChar">Dž</td>
</tr>
<tr>
<td>U+01C4</td>
<td>U+01C6</td>
<td>U+01C5</td>
</tr>
</table>
</aside>
<p><dfn>Case folding</dfn> is the process of making two texts which differ only in case identical for comparison purposes, that is, it is meant for the purpose of string matching. This is distinct from <a>case mapping</a>, which is primarily meant for display purposes. As with the default case mappings, Unicode defines default case fold mappings ("case folding") for each Unicode code point. Unicode defines two forms of case folding, which we'll examine below.</p>
<p>Since most scripts do not have a case distinction, as with case mappings, most Unicode code points do not require a case folding. For those code points that
have a case folding, the majority have a simple, straight-forward mapping to another single matching (generally lowercase) code point. Unicode
calls this set of foldings <code class="kw">common</code>, since both types of case folding defined by Unicode includes these.
</p>
<aside class="example">
<p>Here are some examples of <code class="kw">common</code> case foldings:</p>
<table>
<tr>
<td class="exampleChar">A</td>
<td>⇒</td>
<td class="exampleChar">a</td>
<td><span class="uname">LATIN CAPITAL LETTER A</span> to <span class="uname">LATIN SMALL LETTER A</span></td>
</tr>
<tr>
<td class="exampleChar">Θ</td>
<td>⇒</td>
<td class="exampleChar">θ</td>
<td><span class="uname">GREEK CAPITAL LETTER THETA</span> to <span class="uname">GREEK SMALL LETTER THETA</span></td>
</tr>
<tr>
<td class="exampleChar">Д</td>
<td>⇒</td>
<td class="exampleChar">д</td>
<td><span class="uname">CYRILLIC CAPITAL LETTER DE</span> to <span class="uname">CYRILLIC SMALL LETTER DE</span></td>
</tr>
</table>
</aside>
<p>A few characters have a case folding that map one Unicode code point to two or more code points. This set of case foldings are called the <code class="kw">full</code> case foldings. The <code class=kw>full</code> and <code class=kw>common</code> case foldings are used together to provide the default case folding for all of Unicode. We refer to this form of case folding as <dfn>full casefolding</dfn> or <dfn>Unicode full</dfn> in this document.
</p>
<aside class="example">
<p>One well-known example of a <code class="kw">full</code> case fold mapping is the character <span class="qchar">ß</span>
<span class="uname" translate="no">U+00DF LATIN SMALL LETTER SHARP S</span>, a letter that is commonly used in the German language. The <code class="kw">full</code> case folding and the lower case mapping of this character is to two ASCII letters 's'. The upper case mapping is to "SS".
</p>
<table>
<tr>
<td class="exampleChar">ß</td>
<td>⇒</td>
<td class="exampleChar">ss</td>
<td><span class="uname">LATIN SMALL LETTER SHARP S</span> to <span class="uname">LATIN SMALL LETTER S</span> + <span class="uname">LATIN SMALL LETTER S</span></td>
</tr>
</table>
</aside>
<p>Because some applications cannot allocate additional storage when performing a case fold operation, Unicode provides a <code class="kw">simple</code> case folding that maps a code point that would normally fold to more or fewer code points to use a single code point for comparison purposes instead. Unlike the full folding, this folding invariably alters the content (and potentially the meaning) of the text. As with <a>full casefolding</a>, the <dfn>simple casefolding</dfn> or <dfn>Unicode simple</dfn> casefold, is a combination of <code class=kw>simple</code> and <code class=kw>common</code> mappings so as to cover the full range of Unicode. <a>Unicode simple</a> is not appropriate for use on the Web. </p>
<aside class="example">
<p>Examples of <code class=kw>full</code> versus <code class=kw>simple</code> case fold variations can be found in the Greek script, where several precomposed characters have multi-character case foldings. The table below shows one such example, the character <span class="codepoint" translate="no"><span lang="el">ᾛ</span> [<span class="uname">U+1F9B GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI</span>]</span> and its <code class="kw">full</code> and <code class="kw">simple</code> case foldings:</p>
<table style="width: 100%">
<tr>
<td class="exampleChar">ᾛ</td>
<td>⇒</td>
<td class="exampleChar">ἣι</td>
<td><code class=kw>full</code> case fold: <span class="codepoint" translate="no"><span class="uname">U+1F23 GREEK SMALL LETTER ETA WITH DASIA AND VARIA</span> + <span class="uname">U+03B9 GREEK SMALL LETTER IOTA</span></span></td>
</tr>
<tr>
<td class="exampleChar">ᾛ</td>
<td>⇒</td>
<td class="exampleChar">ᾓ</td>
<td><code class=kw>simple</code> case fold: <span class="codepoint" translate="no"><span class="uname">U+1F93 GREEK SMALL LETTER ETA WITH DASIA AND VARIA AND YPOGEGRAMMENI</span></span></td>
</tr>
</table>
</aside>
<p>Note that case folding removes information from a string which cannot be recovered later. For example, two <span class="qchar">s</span> letters in German do not necessarily represent <span class="qchar">ß</span> in unfolded text.</p>
<section id="caseMappingLanguageSensitivity">
<h3>Language Sensitivity</h3>
<p>Another aspect of case mapping and case folding is that it can be language sensitive.
Unicode defines <em>default</em> case mappings and case foldings for each encoded character, but
these are only defaults and are not appropriate in all cases. Some
languages need case mapping to be tailored to meet specific linguistic
needs. One example of this are Turkic languages written in the
Latin script:</p>
<aside class="example">
<table>
<tr>
<th colspan=4>Default Folding</th>
</tr>
<tr>
<td class="exampleChar">I</td>
<td>⇒</td>
<td class="exampleChar">i</td>
<td>Default folding of letter I</td>
</tr>
<tr>
<th colspan=4>Turkic Language Folding</th>
</tr>
<tr>
<td class="exampleChar">I</td>
<td>⇒</td>
<td class="exampleChar">ı</td>
<td>Turkic language folding of dotless (ASCII) letter I</td>
</tr>
<tr>
<td class="exampleChar">İ</td>
<td>⇒</td>
<td class="exampleChar">i</td>
<td>Turkic language folding of dotted letter I</td>
</tr>
</table>
</aside>
<p>While the example above (and this document in general) focuses on case folding for the purpose of matching, note that case mapping is also language-specific. The name of the second largest city in Turkey is "<code>Diyarbakır</code>", which
contains both the dotted and dotless letters <span class="qchar">i</span>.
</p>
<aside class="example">
<p><span class="exampleChar">Diyarbakır</span> ⇒ <code>text-transform: uppercase</code> ⇒ <span class="exampleChar">DİYARBAKIR</span></p>
<p>Notice that the ASCII letter <span class="codepoint"><span lang="tr">i</span> [<span class="uname">U+0069 LATIN SMALL LETTER I</span>]</span> maps to <span class="codepoint"><span lang="tr">İ</span> [<span class="uname">U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE</span>]</span>, while the letter <span class="codepoint"><span lang="tr">ı</span> [<span class="uname">U+0131 LATIN SMALL LETTER DOTLESS I</span>]</span> maps to the ASCII uppercase <span class="codepoint"><span lang="tr">I</span> [<span class="uname">U+0049 LATIN CAPITAL LETTER I</span>]</span>. Failure to apply this localized case mapping would change the meaning of the text in Turkish, even though this is the expected mapping in other languages, such as English or German.</p>
<p>This language-specific tailoring can also be applied to case folding. For example, if the uppercase text needed to be matched against some set of strings in a case-insensitive way:</p>
<p><span class="exampleChar">DİYARBAKIR</span> ⇒ <code>case fold</code> ⇒ <span class="exampleChar">diyarbakır</span></p>
</aside>
</section>
<section id="caseFoldApplication">
<h3>Uses for Case Folding</h3>
<p>Some document formats or protocols seek to aid interoperability or provide an aid to content authors by ignoring case variations in the <a data-lt="vocabulary">vocabulary</a> they define or in <a>user-supplied values</a> permitted by the format or protocol.</p>
<aside class="example">
<p>One example where this occurs is when matching element names between an HTML document and its associated style sheet. Consider this HTML fragment: </p>
<pre><style type="text/css">
SPAN.hello {
text-decoration: underline;
}
</style>
<span class="hello">Hello World!</span>
</pre>
<p>The <code class="kw" translate="no">SPAN</code> in the stylesheet
matches the <code class="kw" translate="no">span</code> element in the
document, even though the stylesheet uses uppercase and the HTML markup
does not.</p>
</aside>
<p>Sometimes case can vary in a way that is not semantically meaningful
or is not fully under the user's control. This is particularly true
when searching a document, but may sometimes also apply
when defining rules for matching user- or content-generated values,
such as identifiers. In these situations, case-<em>in</em>sensitive
matching might be desirable instead.</p>
<p>When defining a <a>vocabulary</a>, one important consideration is whether the values are restricted to the ASCII [[ASCII]] subset of Unicode or if the vocabulary permits the use of characters (such as accents on Latin letters or a broad range of Unicode including non-Latin scripts) that potentially have more complex case folding requirements. To address these different requirements, there are four types of casefold matching defined by this document for the purposes of string identity matching in document formats or protocols:</p>
<p id="case-sensitive"><dfn data-lt="case-sensitive">Case sensitive matching</dfn>: code points are compared directly with no case folding.</p>
<p id="aci"><dfn data-lt="ASCII case-insensitive|ASCII case-insensitive matching">ASCII case-insensitive matching</dfn> is <a href="https://infra.spec.whatwg.org/#ascii-case-insensitive">defined</a> in [[INFRA]]. This definition compares two sequences of code points as if all ASCII code points in the range 0x41 to 0x5A (A to Z) were mapped to the corresponding code points in the range 0x61 to 0x7A (a to z). ASCII case-insensitive matching can be required when a <a>vocabulary</a> is itself constrained to ASCII.</p>
<p id="uci"><dfn data-lt="Unicode case-insensitive|Unicode case-insensitive matching">Unicode case-insensitive matching</dfn> compares two sequences of code points as if the <a>Unicode full</a> casefolding (see above) had been applied to both input sequences.</p>
<p><dfn>Language-sensitive case-sensitive matching</dfn> is useful in the rare case where a document format or protocol contains information about the language of the syntactic content and where language-sensitive case folding might sensibly be applied. These case foldings are defined in the <cite>Common Locale Data Repository</cite> [[UAX35]] project of the Unicode Consortium.</p>
<p>For advice on how to handle case folding see <a href="#handlingCaseFolding"></a>.</p>
</section>
</section>
<section id="unicodeNormalization">
<h3>Unicode Normalization</h3>
<p>A different kind of variation can occur in Unicode text: sometimes several different <a>Unicode code point</a> sequences can be used to represent the same abstract character. When searching or matching text by comparing code points, these variations in encoding cause text values not to match that users expect to be the same. </p>
<aside class=example id=aringExample title="Encoding Variations">
<p>Consider the character <span class="codepoint"><span lang="en">Ǻ</span> [<span class="uname">U+01FA LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE</span>]</span>. One way to encode this character is as <span class="uname" translate="no"> U+01FA LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE</span>. Here are some of the different character sequences that a document could use to represent this character:</p>
<table>
<tr>
<td class=exampleChar style="width:10%">Ǻ</td>
<td><span class="uname" translate="no">U+01FA</span>—A "precomposed" character.</td>
</tr>
<tr>
<td class=exampleChar>Ǻ</td>
<td><span class="uname" translate="no">A + U+030A + U+0301</span>— A <span class="qterm">base</span> letter <span class="qchar">A</span> followed by two combining marks (<span class="uname" translate="no">U+030A COMBINING RING ABOVE</span> and <span class="uname" translate="no">U+0301 COMBINING ACUTE ACCENT</span>)</td>
</tr><tr>
<td class=exampleChar>Ǻ</td>
<td><span class="uname" translate="no">U+00C5 + U+0301</span>—An accented letter (<span class="uname" translate="no">U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE</span>) followed by a combining accent (<span class="uname" translate="no">U+0301 COMBINING ACUTE ACCENT</span>)</td>
</tr><tr>
<td class=exampleChar>Ǻ</td>
<td><span class="uname" translate="no">U+212B + U+0301</span>—A compatibility character (<span class="uname" translate="no">U+212B ANGSTROM SIGN</span>) followed by a combining accent (<span class="uname" translate="no">U+0301 COMBINING ACUTE ACCENT</span>)</td>
</tr><tr>
<td class=exampleChar>Ǻ</td>
<td><span class="uname" translate="no">U+FF21 + U+030A + U+0301</span>— A compatibility character <span class="uname" translate="no">U+FF21 FULLWIDTH LATIN LETTER CAPITAL A</span>) followed by two combining marks (<span class="uname" translate="no">U+030A COMBINING RING ABOVE</span> and <span class="uname" translate="no">U+0301 COMBINING ACUTE ACCENT</span>)</td>
</tr>
</table>
<p>Each of the above strings contains the same apparent <span class="quote">meaning</span> as <span class="codepoint"><span lang="en">Ǻ</span> [<span class="uname">U+01FA LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE</span>]</span>, but each one is encoded slightly differently. More variations are possible, but are omitted for brevity.</p>
</aside>
<p>Because applications need to find the semantic equivalence in texts
that use different code point sequences, Unicode defines a means of
making two semantically equivalent texts identical: the Unicode
Normalization Forms [[!UAX15]].</p>
<aside class="addition">
<div class="note-title marker"><span>Note Well</span></div>
<p>Unicode Normalization does not guarantee that two
identical-appearing strings that are in a given Unicode Normalization Form use the same sequence of code points.
See <a href="#normalizationLimitations"></a> for more information.</p>
</aside>
<p><a>Resources</a> are often susceptible to the effects of these variations because their specifications and implementations on the Web do not require Unicode Normalization of the text, nor do they take into consideration the string matching algorithms used when processing the <a>syntactic content</a> (including <a>user-supplied values</a>) and <a>localizable content</a> later. For this reason, content developers need to ensure that they have provided a consistent representation in order to avoid problems later.</p>
<p>However, it can be difficult for users to assure that a given <a>resource</a>
or set of resources uses a consistent textual representation because
the differences are usually not visible when viewed as text. Tools and
implementations thus need to consider the difficulties experienced by
users when visually or logically equivalent strings that "ought to"
match (in the user's mind) are considered to be distinct values.
Providing a means for users to see these differences and/or normalize
them as appropriate makes it possible for end users to avoid failures
that spring from invisible differences in their source documents. For
example, the W3C Validator warns when an HTML document is not fully in
Unicode Normalization Form C.</p>
<section id="canonical_compatibility">
<h4>Canonical vs. Compatibility Equivalence</h4>
<p>Unicode defines two types of equivalence between characters: <em>canonical equivalence</em> and <em>compatibility equivalence</em>.</p>
<p><dfn>Canonical equivalence</dfn> is a fundamental equivalency between Unicode code points or sequences of Unicode code points that represent the same abstract character. Canonically equivalent sequences ideally should have the same visual appearance (although there are many factors that can cause them to appear somewhat differently) and they should be treated and processed as if they were identical. Unicode defines a process called <em>canonical decomposition</em> that removes these primary distinctions between two differently-encoded but canonically equivalent texts.</p>
<p>Examples of canonical equivalence defined by Unicode include:</p>
<ul class="dropExampleList">
<li class="dropExampleItem"><span class="dropExample">Ç<span style="font-size:75%">
vs.</span>Ç</span> <em>Precomposed versus combining
sequences.</em> Some characters can be composed from a base
character followed by one or more combining characters. The same
characters are sometimes also encoded as a distinct "precomposed"
character. In this example, the character <span class="codepoint"><span lang="en">Ç</span> [<span class="uname">U+00C7 LATIN CAPITAL LETTER C WITH CEDILLA</span>]</span> is canonically equivalent to the character sequence starting with the base character <span class="codepoint"><span lang="en">C</span> [<span class="uname">U+0043 LATIN CAPITAL LETTER C</span>]</span> followed by <span class="codepoint"><span lang="en">◌̧</span> [<span class="uname">U+0327 COMBINING CEDILLA</span>]</span>. Such equivalence can extend to characters with multiple combining marks.</li>
<li class="dropExampleItem"><span class="dropExample">q̣̇<span style="font-size:75%">
vs.</span>q̣̇</span> <em>Order of combining marks.</em> When a base character is modified by multiple combining marks, the order of the combining marks might not represent a distinct character. Here the sequence <span class="codepoint"><span lang="en">q</span> [<span class="uname">U+0071 LATIN SMALL LETTER Q</span>]</span> <span class="codepoint"><span lang="en"> ̇</span> [<span class="uname">U+0307 COMBINING DOT ABOVE</span>]</span> <span class="codepoint"><span lang="en"> ̣</span> [<span class="uname">U+0323 COMBINING DOT BELOW</span>]</span> and <span class="codepoint"><span lang="en">q</span> [<span class="uname">U+0071 LATIN SMALL LETTER Q</span>]</span> <span class="codepoint"><span lang="en"> ̣</span> [<span class="uname">U+0323 COMBINING DOT BELOW</span>]</span> <span class="codepoint"><span lang="en"> ̇</span> [<span class="uname">U+0307 COMBINING DOT ABOVE</span>]</span> are equivalent, even though the combining marks are in a different order. Note that this example is chosen carefully: the dot-above character and dot-below character are on opposite "sides" of the base character. The order of combining diacritics on the same side often has a positional meaning (although there are cases where the order doesn't matter to the presentation).</li>
<li class="dropExampleItem"><span class="dropExample">Ω<span style="font-size:75%">
vs.</span>Ω</span> <em>Singleton mappings.</em> These result from the need to separately encode otherwise equivalent characters to support legacy character encodings. In this example, the Ohm symbol <span class="codepoint"><span lang="en">Ω</span> [<span class="uname">U+2126 OHM SYMBOL</span>]</span> is canonically equivalent (and identical in appearance) to the Greek letter Omega <span class="codepoint"><span lang="el">Ω</span> [<span class="uname">U+03A9 GREEK CAPITAL LETTER OMEGA</span>]</span>. (Another example of a singleton is <span class="codepoint"><span lang="en">Å</span> [<span class="uname">U+212B ANGSTROM SIGN</span>]</span> in the <a href="#aringExample">encoding variations example</a> above)</li>
<li class="dropExampleItem"><span class="dropExample">가<span style="font-size:75%">
vs.</span>가</span> <em>Hangul.</em> The Hangul script is
used to write the Korean language. This script is constructed
logically, with each syllable being a roughly-square <a>grapheme</a>
formed from specific sub-parts that represent consonants and
vowels. These specific sub-parts, called <em>jamo</em>, are
encoded in Unicode. So too are the precomposed syllables. Thus the
syllable <span class="codepoint"><span lang="ko">가</span> [<span class="uname">U+AC00 [Hangul Syllable, First]</span>]</span> is canonically equivalent to its constituent <em>jamo</em> characters <span class="codepoint" translate="no"><span lang="ko">가</span> [<span class="uname">U+1100 HANGUL CHOSEONG KIYEOK</span> + <span class="uname">U+1161 HANGUL JUNGSEONG A</span>]</span>.</li>
</ul>
<p><dfn>Compatibility equivalence</dfn> is a weaker equivalence
between Unicode characters or sequences of Unicode characters that represent the
same abstract character, but may have a different visual appearance
or behavior. Generally the process called <em>compatibility decomposition</em> removes
formatting variations, such as superscript, subscript, rotated,
circled, and so forth, but other variations also occur. In many
cases, characters with compatibility decompositions represent a
distinction of a semantic nature; replacing the use of distinct
characters with their compatibility decomposition can therefore
change the meaning of the text. Texts that are equivalent after
compatibility decomposition often were not perceived as being
identical beforehand and SHOULD NOT be treated as equivalent by a formal
language.</p>
<aside class=example>
<p>The following table illustrates various kinds of compatibility equivalence in Unicode:</p>
<table class=data>
<thead>
<tr>
<th>Compatibility Equivalance</th>
<th style="text-align:center">Original Character</th>
<th></th>
<th style="text-align:center; width:30%">Compatibility Mapping</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan=2><strong>Font variants</strong>—characters that have a specific visual appearance (generally associated with a specialized use, such as in mathematics).</td>
<td style="text-align: center"><span class="exampleChar">ℌ</span><br><span class=uname>U+210C</span></td>
<td style="text-align: center" rowspan=2>⇒</td>
<td style="text-align: center" rowspan=2><span class="exampleChar">H</span><br><span class=uname>U+0048</span></td>
</tr>
<tr>
<td style="text-align: center"><span class="exampleChar">ℍ</span><br><span class=uname>U+210D</span></td>
</tr>
<tr>
<td><strong>Breaking versus non-breaking</strong>—variations in breaking or joining rules, such as the difference between a <span class="qterm">normal</span> and a non-breaking space.</td>
<td style="text-align: center"><span class="uname" translate="no">NON-BREAKING SPACE</span><br><span class=uname>U+00A0</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="uname" translate="no">SPACE<br>U+0020</span></td>
</tr>
<tr>
<td rowspan=4><strong>Presentation forms of Arabic</strong>— characters that encode the specific shapes (isolated, final, initial, and medial) needed by visual legacy encodings of the Arabic script.</td>
<td style="text-align: center"><span class="exampleChar">ﻩ</span><br><span class=uname>U+FEE9</span></td>
<td style="text-align: center" rowspan=4>⇒</td>
<td style="text-align: center" rowspan=4><span class="exampleChar">ه</span><br><span class=uname>U+0647</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">ﻪ</span><br><span class=uname>U+FEEA</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">ﻫ</span><br><span class=uname>U+FEEB</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">ﻬ</span><br><span class=uname>U+FEEC</span></td>
</tr>
<tr>
<td rowspan=4><strong>Circled</strong>—numbers, letters, and other characters in a circled, bullet, or other presentational form; often used for lists, footnotes, and specialized presentation</td>
<td style="text-align: center"><span class="exampleChar">①</span><br><span class=uname>U+2460</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">1</span><br><span class=uname>U+0031</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">⑩</span><br><span class=uname>U+2469</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">10</span><br><span class=uname>U+0031 U+0030</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">Ⓐ</span><br><span class=uname>U+24B6</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">A</span><br><span class=uname>U+0041</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">㊞</span><br><span class=uname>U+329E</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">印</span><br><span class=uname>U+5370</span></td>
</tr>
<tr>
<td rowspan=4><strong>Width variation, size, rotated presentation forms</strong>—narrow vs. wide presentational forms of characters (such as those associated with legacy multibyte encodings), as well as "rotated" presentation forms necessary for vertical text.</td>
<td style="text-align: center"><span class="exampleChar">カ</span><br><span class=uname>U+FF76</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">カ</span><br><span class=uname>U+30AB</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">︷</span><br><span class=uname>U+FE37</span></td>
<td style="text-align: center" rowspan=2>⇒</td>
<td style="text-align: center" rowspan=2><span class="exampleChar">{</span><br><span class=uname>U+007B</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">{</span><br><span class=uname>U+FF5B</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">A</span><br><span class=uname>U+FF21</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">A</span><br><span class=uname>U+0041</span></td>
</tr>
<tr>
<td rowspan=4><strong>Superscripts/subscripts</strong>—superscript or subscript letters, numbers, and symbols.</td>
<td style="text-align: center"><span class="exampleChar">⁹</span><br><span class=uname>U+2079</span></td>
<td style="text-align: center" rowspan=2>⇒</td>
<td style="text-align: center" rowspan=2><span class="exampleChar">9</span><br><span class=uname>U+0039</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">₉</span><br><span class=uname>U+2089</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">ª</span><br><span class=uname>U+00AA</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">a</span><br><span class=uname>U+0061</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">₊</span><br><span class=uname>U+208A</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">+</span><br><span class=uname>U+002B</span></td>
</tr>
<tr>
<td rowspan=4><strong><span class="quote">Squared</span> characters</strong>—East Asian (particularly kana) sequences encoded as a presentation form to fit in a single ideographic "cell" in text.</td>
<td style="text-align: center"><span class="exampleChar">㌀</span><br><span class=uname>U+3300</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">アパート</span><br><span class=uname>U+30A2 U+30D1 U+30FC U+30C8</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">㍐</span><br><span class=uname>U+3350</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">ユアン</span><br><span class=uname>U+30E6 U+30A2 U+30F3</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">㉐</span><br><span class=uname>U+3250</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">PTE</span><br><span class=uname>U+0050 U+0054 U+0045</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">㎉</span><br><span class=uname>U+3389</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">kcal</span><br><span class=uname>U+006B U+0063 U+0061 U+006C</span></td>
</tr>
<tr>
<td rowspan=4><strong>Fractions</strong>—precomposed vulgar fractions, often encoded for compatibility with font glyph sets.</td>
<td style="text-align: center"><span class="exampleChar">¼</span><br><span class=uname>U+00BC</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">1⁄4</span><br><span class=uname>U+0031 U+2044 U+0034</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">½</span><br><span class=uname>U+00BD</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">1⁄2</span><br><span class=uname>U+0031 U+2044 U+0032</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">⅟</span><br><span class=uname>U+215F</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">1⁄</span><br><span class=uname>U+0031 U+2044</span></td>
</tr><tr>
<td style="text-align: center"><span class="exampleChar">↉</span><br><span class=uname>U+2189</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">0⁄3</span><br><span class=uname>U+0030 U+2044 U+0033</span></td>
</tr>
<tr>
<td rowspan=4><strong>Others</strong>—compatibility characters encoded for other reasons, generally for compatibility with legacy character encodings. Many of these characters are simply a sequence of characters encoded as a single presentational unit.</td>
<td style="text-align: center"> <span class="exampleChar">dž</span><br><span class=uname>U+01C6</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">dž</span><br><span class=uname>U+0064 U+017E</span></td>
</tr><tr>
<td style="text-align: center"> <span class="exampleChar">⑴</span><br><span class=uname>U+2474</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">(1)</span><br><span class=uname>U+0028 U+0031 U+0029</span></td>
</tr><tr>
<td style="text-align: center"> <span class="exampleChar">⒈</span><br><span class=uname>U+2488</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">1.</span><br><span class=uname>U+0031 U+002E</span></td>
</tr><tr>
<td style="text-align: center"> <span class="exampleChar">⻳</span><br><span class=uname>U+2EF3</span></td>
<td style="text-align: center">⇒</td>
<td style="text-align: center"><span class="exampleChar">龟</span><br><span class=uname>U+9F9F</span></td>
</tr>
</tbody>
</table>
</aside>
<p>In the above table, it is important to note that the characters
illustrated are <em>actual Unicode codepoints</em>, not just presentational
variations due to context or style. Each character was
encoded into Unicode for compatibility with various legacy character
encodings. They should not be confused with the normal kinds of
presentational processing used on their non-compatibility
counterparts.</p>
<p>For example, most Arabic-script text uses the characters in the Arabic script block of Unicode (starting at <span class="uname" translate="no">U+0600</span>). The actual glyphs used to display the text are selected using fonts and text processing logic based on the position inside a word (initial, medial, final, or isolated), in a process called "shaping". In the table above, the four presentation forms of the Arabic letter <span class="codepoint"><span lang="ar" dir="rtl">ه</span> [<span class="uname">U+0647 ARABIC LETTER HEH</span>]</span> are shown. The characters shown are compatibility characters in the <span class="uname" translate="no">U+FE00</span> block, each of which represents a specific "positional" shape and each of the four code points shown have a compatibility decomposition to the <span class="quote">regular</span> Arabic letter <span class="codepoint"><span lang="ar" dir=rtl>ه</span> [<span class="uname">U+0647 ARABIC LETTER HEH</span>]</span>. These presentation forms are intended only for the support of round-trip encoding conversions with the <a>legacy character encodings</a> that include equivalent presentation forms. Otherwise a string containing a sequence of letters 'heh' is just encoded as a series of <span class=uname translate=no>U+0647</span> code points, with the rendering system and font supplying the appropriate shapes.
<aside class=example id=bidiCompatibilityExample>
<p>Example of a sequence of <span class=uname translate=no>U+0647 ARABIC LETTER HEH</span>. The different letter shapes are provided by the rendering system. Note that Arabic is read from right-to-left, so the "isolated" shape is on the right side of the string (followed by a space), then "initial", "medial", and "final" shapes.</p>
<p dir=rtl class=bidiExample>ه ههه</p>
</aside>
<p>Similarly, the variations in half-width and full-width forms and rotated
characters (for use in vertical text) are encoded as separate code
points, mainly for compatibility with legacy character encodings. In
many cases these variations are associated with the Unicode properties
described in <cite>East Asian Width</cite> [[UAX11]]. See also <cite>Unicode
Vertical Text Layout</cite> [[UTR50]] for a discussion of vertical text
presentation forms.</p>
<p>In the case of characters with compatibility decompositions, such
as those shown above, the <span class="qchar">K</span> Unicode
Normalization forms convert the text to the "normal" or "expected"
Unicode code point. But the existence of these compatibility
characters cannot be taken to imply that similar appearance
variations produced in the normal course of text layout and
presentation are affected by Unicode Normalization. They are not.</p>
</section>
<section id="composition_decomposition">
<h4>Composition vs. Decomposition</h4>
<p>These two types of Unicode-defined equivalence are then grouped by another pair of variations: "decomposition" and "composition". In "decomposition", separable logical parts of a visual character are broken out into a sequence of base characters and combining marks and the resulting code points are put into a fixed, canonical order. In "composition", the decomposition is performed and then combining marks are recombined according to certain rules with their base characters.</p>
<div class="warning">
<p>Roughly speaking, <abbr title="Normalization Form C">NFC</abbr> is defined such that each combining character sequence (a base character followed by one or more combining characters) is replaced, as far as possible, by a canonically equivalent precomposed character.</p>
<p>It is rather important to notice what this does <strong>not</strong> mean. The resulting character sequence can still contain combining marks, since not all character sequences have a precomposed equivalent. Indeed, as we've seen, many scripts offer no alternative to the use of combining marks, such as the Devanagari vowels in <a href="#graphemeExample">this example</a>. In other cases, a given base character and combining mark is not replaced with a precomposed character because the combination is blocked by normalization rules. For example, some Indic scripts do not compose certain sequences of base plus diacritic, even though a matching precomposed character exists, due to composition exclusion rules. Composition may also be blocked by another combining mark between the two characters that would otherwise combine.</p>
</div>
</section>
<section id="normalization_forms">
<h4>Unicode Normalization Forms</h4>
<p>There are four Unicode Normalization Forms. Each form is named using a letter code: </p>
<ul>
<li><strong>D</strong> (or NFD) stands for <em>canonical Decomposition</em>.</li>
<li><strong>C</strong> (or NFC) stands for <em>Composition</em>, which is canonical decomposition followed by composition.</li>
<li><strong>KD</strong> (or NFKD) stands for <em>Kompatibility decomposition</em> (K because the letter C is already used).</li>
<li><strong>KC</strong> (or NFKC) stands for compatibility decomposition followed by composition.</li>
</ul>
<aside class=example>
<p>Having converted a resource to a sequence of Unicode characters and unescaped any escape sequences, we can finally "normalize" the Unicode texts given in the <a href="#aringExample">example</a> above. Here are the resulting sequences in each Unicode Normalization form for the <span class=uname>U+01FA</span> example given earlier. Note that there are only three distinct code point sequences between the various normalized forms (<span class=uname>U+01FA</span>, <span class=uname>U+0041 U+030A U+0301</span>, and <span class=uname>U+FF21 U+030A U+0301</span>):</p>
<table style="border:1px solid black; vertical-align:center; table-layout:fixed; text-align:center; column-width:200px;">
<thead>
<tr>
<th class=tableHead>Original Codepoints</th>
<th class=tableHead>NFC</th>
<th class=tableHead>NFD</th>
<th class=tableHead>NFKC</th>
<th class=tableHead>NFKD</th>
</tr>
</thead>
<tr>
<td class=b-clear>Ǻ</td>
<td class=b-clear rowspan=7>Ǻ</td>
<td class=b-clear rowspan=7>Ǻ</td>
<td class=b-clear rowspan=9>Ǻ</td>
<td class=b-clear rowspan=9>Ǻ</td>
</tr>
<tr>
<td class=tableSub>U+01FA</td>
</tr>
<tr>
<td class=b-clear>Ǻ</td>
</tr>
<tr>
<td class=tableSub>U+00C5<br>U+0301</td>
</tr>
<tr>
<td class=b-clear>Ǻ</td>
</tr>
<tr>
<td class=tableSub>U+212B<br>U+0301</td>
</tr>
<tr>
<td class=b-clear>Ǻ</td>
</tr>
<tr>
<td class=tableSub>U+0041<br>U+030A<br>U+0301</td>
<td class=tableSub>U+01FA</td>
<td class=tableSub>U+0041<br>U+030A<br>U+0301</td>
</tr>
<tr>
<td class=b-clear>Ǻ</td>
<td class=b-clear>Ǻ</td>
<td class=b-clear>Ǻ</td>
</tr>
<tr>
<td class=tableSub>U+FF21<br>U+030A<br>U+0301</td>
<td class=tableSub>U+FF21<br>U+030A<br>U+0301</td>
<td class=tableSub>U+FF21<br>U+030A<br>U+0301</td>
<td class=tableSub>U+01FA</td>
<td class=tableSub>U+0041<br>U+030A<br>U+0301</td>
</tr>
</table>
</aside>
<p>Unicode Normalization reduces these (and other potential sequences
of escapes representing the same character) to just three possible
variations. However, Unicode Normalization doesn't remove all
textual distinctions and sometimes the application of Unicode
Normalization can remove meaning that is distinctive or meaningful
in a given context. For example: </p>
<ul>
<li>Not all compatibility characters have a compatibility
decomposition.</li>
<li>Some characters that look alike or have similar semantics are actually distinct in Unicode and don't have canonical or compatibility decompositions to link them together. For example, <span class="codepoint"><span lang="zh">。</span> [<span class="uname">U+3002 IDEOGRAPHIC FULL STOP</span>]</span> is used as a <span class="quote">period</span> at the end of sentences in languages such as Chinese or Japanese. However, it is not considered equivalent to the ASCII <span class="quote">period</span> character <span class="codepoint"><span lang="en">.</span> [<span class="uname">U+002E FULL STOP</span>]</span>.</li>
<li>Some character variations are not handled by the Unicode
Normalization Forms. For example, UPPER, Title, and lowercase
variations are a separate and distinct textual variation that must