Movatterモバイル変換


[0]ホーム

URL:


[Unicode] Technical Reports
 

Unicode® Standard Annex #31

Unicode Identifier and Pattern Syntax

VersionUnicode 11.0.0
EditorsMarkDavis (markdavis@google.com)
Date2018-06-04
This Versionhttp://www.unicode.org/reports/tr31/tr31-29.html
Previous Versionhttp://www.unicode.org/reports/tr31/tr31-27.html
Latest Versionhttp://www.unicode.org/reports/tr31/
Latest Proposed Updatehttp://www.unicode.org/reports/tr31/proposed.html
Revision29

Summary

This annex describes specifications for recommended defaultsfor the use of Unicode in the definitions of general-purpose identifiers, immutable identifiers, hashtag identifiers, and inpattern-based syntax. It also supplies guidelines for use ofnormalization with identifiers.

Status

This document has been reviewed by Unicode members and otherinterested parties, and has been approved for publication by theUnicode Consortium. This is a stable document and may be used asreference material or cited as a normative reference by otherspecifications.

A Unicode Standard Annex (UAX) forms an integral partof the Unicode Standard, but is published online as a separatedocument. The Unicode Standard may require conformance to normativecontent in a Unicode Standard Annex, if so specified in theConformance chapter of that version of the Unicode Standard. Theversion number of a UAX document corresponds to the version of theUnicode Standard of which it forms a part.

Please submit corrigenda and other comments with the onlinereporting form [Feedback].Related information that is useful in understanding this annex isfound in Unicode Standard Annex #41, “CommonReferences for Unicode Standard Annexes.” For the latest version ofthe Unicode Standard, see [Unicode]. For alist of current Unicode Technical Reports, see [Reports]. For moreinformation about versions of the Unicode Standard, see [Versions]. For anyerrata which may apply to this annex, see [Errata].

Contents


1Introduction

A common task facing an implementer of the Unicode Standard is theprovision of a parsing and/or lexing engine for identifiers, such asprogramming language variables or domain names.There are also realms where identifiers need to be defined with an extended set ofcharacters to align better with what end users expect, such as inhashtags.

To assist in the standard treatment of identifiers in Unicodecharacter-based parsers and lexical analyzers, a set ofspecifications is provided here as abasis for parsing identifiers that contain Unicode characters. These specificationsinclude:

These guidelines follow the typical pattern of identifiersyntax rules in common programming languages, by defining an ID_Startclass and an ID_Continue class and using a simple BNF rule foridentifiers based on those classes; however, the composition of thoseclasses is more complex and contains additional types of characters,due to the universal scope of the Unicode Standard.

This annex also provides guidelines for the user of normalization andcase insensitivity with identifiers, expanding on a section that wasoriginally in Unicode Standard Annex #15, “Unicode NormalizationForms” [UAX15].

The specification in this annex provides a definition of identifiersthat is guaranteed to be backward compatible with each successiverelease of Unicode, but also allows any appropriate new Unicodecharacters to become available in identifiers. In addition, Unicodecharacter properties for stable pattern syntax are provided. Theresulting pattern syntax is backward compatibleand forwardcompatible over future versions of the Unicode Standard. Theseproperties can either be used alone or in conjunction with theidentifier characters.

Figure 1 shows the disjoint categories of code points definedin this annex. (The sizes of the boxes are not to scale.)

Figure 1.CodePoint Categories for Identifier Parsing

Pattern_Syntax
CharactersUnassigned CodePoints
Pattern_White_Space
Characters
ID_Start
Characters
ID_Nonstart
Characters
Other Assigned
CodePoints

The set consisting of the union ofID_Start andID_Nonstartcharacters is known asIdentifier Characters and has thepropertyID_Continue. TheID_Nonstart set is defined asthe set differenceID_Continue minusID_Start: it isnot a formal Unicode property. While lexical rules are traditionallyexpressed in terms of the latter, the discussion here is simplifiedby referring to disjoint categories.

1.1Stability

There are certain features that developers can depend on forstability:

In successive versions of Unicode, the only allowed changes ofcharacters from one of the above classes to another are those listedwith a plus sign (+) inTable 1.

Table 1.PermittedChanges in Future Versions

 ID_StartID_NonstartOther Assigned
Unassigned
Other Assigned 
ID_Nonstart  

The Unicode Consortium has formally adopted a stability policy onidentifiers. For more information, see [Stability].

1.2Customization

Each programming language standard has its own identifiersyntax; different programming languages have different conventionsfor the use of certain characters such as $, @, #, and _ inidentifiers. To extend such a syntax to cover the full behavior of aUnicode implementation, implementers may combine those specific ruleswith the syntax and properties provided here.

Each programming language can define its identifier syntax asrelativeto the Unicode identifier syntax, such as saying that identifiers aredefined by the Unicode properties, with the addition of “$”. Byaddition or subtraction of a small set of language specificcharacters, a programming language standard can easily track agrowing repertoire of Unicode characters in a compatible way. SeealsoSection 2.5,BackwardCompatibility.

Similarly, each programming language can define its ownwhitespace characters or syntax characters relative to the UnicodePattern_White_Space or Pattern_Syntax characters, with some specifiedset of additions or subtractions.

Systems that want to extend identifiers to encompass words used innatural languages, or narrow identifiers for security may do so asdescribed inSection 2.3,Layout and FormatControl Characters,Section 2.4,Specific CharacterAdjustments, andSection 5,Normalization and Case.

To preserve the disjoint nature of the categories illustrated inFigure1, any characteradded to one of the categories must besubtractedfrom the others.

Note: In many cases there are importantsecurity implications that may require additional constraints onidentifiers. For more information, see [UTR36].

1.3DisplayFormat

Implementations may use a format fordisplaying identifiersthat differs from the internal form used tocompareidentifiers. For example, an implementation might display format whatthe user has entered, but use a normalized format for comparison.Examples of this include:

Case.The display format retains case differences,but the comparison format erases them by using Case_Folding. Thus“A” and its lowercase variant “a” would be treated as the sameidentifier internally, even though they may have been inputdifferently and may display differently.

Variants.The display format retains variantdistinctions, such as halfwidth versus fullwidth forms, or betweenvariation sequences and their base characters, but the comparisonformat erases them by using NFKC_Case_Folding. Thus “A” and itsfull-width variant “A” would be treated as the same identifierinternally, even though they may have been input differently and maydisplay differently.

For an example of the use of display versus comparison formats seeUTS#46: Unicode IDNA Compatibility Processing [UTS46]. For more informationabout normalization and case in identifiers seeSection 5,Normalization and Case.

1.4Conformance

The following describes the possible ways that animplementation can claim conformance to this specification.

UAX31-C1. An implementationclaiming conformance to this specification shall identify theversion of this specification.

UAX31-C2. An implementationclaiming conformance to this specification shall describe which ofthe following requirements it observes:

2Default Identifiers

The formal syntax provided here captures the general intentthat an identifier consists of a string of characters beginning witha letter or an ideograph, and followed by any number of letters,ideographs, digits, or underscores. It provides a definition ofidentifiers that is guaranteed to be backward compatible with eachsuccessive release of Unicode, but also adds any appropriate newUnicode characters.

The formulations allow for extensions, alsoknown asprofiles. That is, the particular set of code points foreach category used by the syntax can be customized according to therequirements of the environment.

If such extensions include characters from Pattern_White_Space orPattern_Syntax, then such identifiers do not conform to an unmodifiedR3. Pattern_White_Space and Pattern_SyntaxCharacters. However, such extensions may often be necessary. Forexample, Java and C++ identifiers include ‘$’, which is aPattern_Syntax character.

UAX31-D1.DefaultIdentifier Syntax:

<Identifier> := <Start> <Continue>*(<Medial> <Continue>+)*

Identifiers are defined by assigning thesets of lexical classes defined as properties in the UnicodeCharacter Database [UAX44]. These properties are shown inTable 2. Thefirst column shows the property name, whose values are defined inthe UCD. The second column provides a general description of thecoverage for the associated class, the derivational relationshipbetween the ID properties and the XID properties, and an associatedset notation for the class.

Table 2.Properties for Lexical Classes forIdentifiers

PropertiesGeneral Description of Coverage
ID_StartID_Start charactersare derived from the UnicodeGeneral_Category of uppercase letters, lowercase letters,titlecase letters, modifier letters, other letters, letternumbers, plus Other_ID_Start, minus Pattern_Syntax andPattern_White_Space code points.

In set notation:
[\p{L}\p{Nl}\p{Other_ID_Start}-\p{Pattern_Syntax}-\p{Pattern_White_Space}]
XID_StartXID_Start characters arederived fromID_Start as perSection 5.1,NFKC Modifications.
ID_ContinueID_Continuecharacters include ID_Start characters, plus characters having theUnicode General_Category of nonspacing marks, spacing combiningmarks, decimal number, connector punctuation, plusOther_ID_Continue , minus Pattern_Syntax and Pattern_White_Spacecode points.

In set notation:
[\p{ID_Start}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\p{Other_ID_Continue}-\p{Pattern_Syntax}-\p{Pattern_White_Space}]
XID_ContinueXID_Continuecharacters are derived fromID_Continue as perSection5.1,NFKC Modifications.

XID_Continuecharacters are also known simply asIdentifier Characters,because they are a superset of theXID_Start characters.

Note that “other letters” includes ideographs. For more about thestability extensions, seeSection 2.5Backward Compatibility.

The innovations in the identifier syntax to cover the UnicodeStandard include the following:

The XID_Start and XID_Continue properties are improved lexicalclasses that incorporate the changes described inSection 5.1,NFKC Modifications. They are recommended for most purposes, especially for security,over the original ID_Start and ID_Continue properties.

UAX31-R1.DefaultIdentifiers:To meet this requirement, to determine whether a stringis an identifier an implementation shall use definitionUAX31-D1, setting Start andContinue to the properties XID_Start and XID_Continue, respectively, and leaving Medial empty.

One such profile may be to use the contents of ID_Start and ID_Continue in place of XID_Start and XID_Continue, for backward compatibility.

Another such profile would be to include some set of the optional characters, for example:

UAX31-R1a.RestrictedFormat Characters: To meet this requirement, an implementationshall define a profile forUAX31-R1 which allows formatcharacters as described in Section 2.3,Layout and FormatControl Characters.

UAX31-R1b.StableIdentifiers: To meet this requirement, an implementation shallguarantee that identifiers are stable across versions of the UnicodeStandard: that is, once a string qualifies as an identifier, it doesso in all future versions.

Note: The UAX31-R1b requirement is typically achieved by usinggrandfathered characters. See Section 2.5,Backward Compatibility. Where profiles are allowed,management of those profiles may also be required to guarantee backwardscompatibility. Typically such management also uses grandfathered characters.

2.1CombiningMarks

Combining marks are accounted for in identifier syntax: a composedcharacter sequence consisting of a base character followed by anynumber of combining marks is valid in an identifier. Combining marksare required in the representation of many languages, and theconformance rules inChapter 3, Conformance, of [Unicode] require theinterpretation of canonical-equivalent character sequences. Thesimplest way to do this is to require identifiers in the NFC format(or transform them into that format); seeSection 5,Normalization and Case.

Enclosing combining marks (such as U+20DD..U+20E0) are excluded fromthe definition of thelexical classID_Continue, because the composite characters that result from their compositionwith letters are themselves not normally considered validconstituents of these identifiers.

2.2ModifierLetters

Modifier letters (General_Category=Lm) are also included in thedefinition of the syntax classes for identifiers. Modifier lettersare often part of natural language orthographies and are useful formaking word-like identifiers in formal languages. On the other hand,modifier symbols (General_Category=Sk), which are seldom a part oflanguage orthographies, are excluded from identifiers. For morediscussion of modifier letters and how they function, see [Unicode].

Implementations that tailor identifier syntax for specialpurposes may wish to take special note of modifier letters, as insome cases modifier letters have appearances, such as raised commas,which may be confused with common syntax characters such as quotationmarks.

2.3Layout and FormatControl Characters

Certain Unicode characters are known asDefault_Ignorable_Code_Points. These include variation selectors andcharacters used to control joining behavior, bidirectional orderingcontrol, and alternative formats for display (having theGeneral_Category value of Cf). The recommendation is to permit themin identifiers only in special cases, listed below. The use ofdefault-ignorable characters in identifiers is problematical, firstbecause the effects they represent are stylistic or otherwise out ofscope for identifiers, and second because the characters themselvesoften have no visible display. It is also possible to misapply thesecharacters such that users can create strings that look the same butactually contain different characters, which can create securityproblems. In such environments, identifiers should also be limited tocharacters that are case-folded and normalized with the NFKC_Casefoldoperation. For more information, seeSection 5,Normalization and Case andUTR#36: Unicode Security Considerations [UTR36].

Variation selectors, in particular, including standardized variantsand sequences from the Ideographic Variation Database, are notincluded in the default identifier syntax. These are subject to thesame considerations as for other Default_Ignorable_Code_Points listedabove. Because variation selectors request a difference in displaybut do not guarantee it, they do not work well in general-purposeidentifiers. The NFKC_Casefold operation can be used to remove them,along with other Default_Ignorable_Code_Points. However, in someenvironments it may be useful to retain variation sequences in thedisplay form for identifiers. For more information, seeSection1.3,Display Format.

For the above reasons, default-ignorable characters are normallyexcluded from Unicode identifiers. However, visible distinctionscreated by certain format characters (particularly theJoin_Controlcharacters) are necessary in certain languages. A blanket exclusionof these characters makes it impossible to create identifiers withthe correct visual appearance for common words or phrases in thoselanguages.

Identifier systems that attempt to provide more naturalrepresentations of terms in "modern, customary usage"should allow these characters in input and display, but limit them tocontexts in which they are necessary. The termmoderncustomary usage includes characters that are in common use innewspapers, journals, lay publications; on street signs; incommercial signage; and as part of common geographic names andcompany names, and so on. It does not include technical or academicusage such as in mathematical expressions, using archaic scripts orwords, or pedagogical use (such as illustration of half-forms orjoining forms in isolation), or liturgical use.

The goals for such a restriction of format characters toparticular contexts are to:

Thus in such circumstances, an implementation should allow thefollowing Join_Control characters in the limited contexts specifiedinA1,A2, andB below.

U+200C ZERO WIDTH NON-JOINER (ZWNJ)
U+200D ZERO WIDTH JOINER(ZWJ)

There are also two global conditions incorporated in each ofA1,A2, andB:

Implementations may also impose tighter restrictions than provided below, in order to eliminate some other circumstances where the characters either have no visual effect or the effect has no semantic importance.

A1. Allow ZWNJ in thefollowing context:

Breaking a cursive connection. That is, in the context basedon the Joining_Type property, consisting of:

This corresponds to the following regular expression (in Perl-stylesyntax):/$LJ ZWNJ $RJ/
where:

$T = \p{Joining_Type=Transparent}
$RJ =[\p{Joining_Type=Dual_Joining}\p{Joining_Type=Right_Joining}]
$LJ = [\p{Joining_Type=Dual_Joining}\p{Joining_Type=Left_Joining}]

For example, consider Farsi <Noon, Alef, Meem, Heh, Alef,Farsi Yeh>. Without a ZWNJ, it translates to "names",as shown in the first row; with a ZWNJ between Heh and Alef, it means"a letter", as shown in the second row ofFigure 2.

Figure 2.Persian Example withZWNJ

AppearanceCode PointsAbbreviated Names
diagram10646 + 0627 + 0645 + 0647 +0627 + 06CCNOON + ALEF + MEEM + HEH + ALEF+ FARSI YEH
diagram20646 + 0627 + 0645 + 0647 +200C + 0627 + 06CCNOON + ALEF + MEEM + HEH + ZWNJ+ ALEF + FARSI YEH

A2. Allow ZWNJ in thefollowing context:

In a conjunct context. That is, a sequence of the form:

This corresponds to the following regular expression (in Perl-stylesyntax):/$L $M* $V $M₁* ZWNJ/
where:

$L = \p{General_Category=Letter}
$V =\p{Canonical_Combining_Class=Virama}
$M = \p{General_Category=Mn}
$M₁ = [\p{General_Category=Mn}&\p{CCC≠0}]

For example, the Malayalam word foreyewitness is shown inFigure3. The form without the ZWNJ in the second row is incorrect in thiscase.

Figure 3.Malayalam Examplewith ZWNJ

AppearanceCode PointsAbbreviated Names
 diagram3 0D26 + 0D43 + 0D15 + 0D4D +200C + 0D38 + 0D3E + 0D15 + 0D4D + 0D37 + 0D3FDA + VOWEL SIGN VOCALIC R + KA+ VIRAMA + ZWNJ + SA + VOWEL SIGN AA + KA + VIRAMA + SSA + VOWELSIGN I
diagram40D26 + 0D43 + 0D15 + 0D4D +0D38 + 0D3E + 0D15 + 0D4D + 0D37 + 0D3FDA + VOWEL SIGN VOCALIC R + KA+ VIRAMA + SA + VOWEL SIGN AA + KA + VIRAMA + SSA + VOWEL SIGN I

B. Allow ZWJ in thefollowing context:

In a conjunct context.That is, a sequence of the form:

This corresponds to the following regular expression (in Perl-stylesyntax): /$L $M* $V $M₁* ZWJ (?!$D)/
where:

$L= \p{General_Category=Letter}
$V =\p{Canonical_Combining_Class=Virama}
$M = \p{General_Category=Mn}
$M₁ = [\p{General_Category=Mn}&\p{CCC≠0}]
$D = \p{Indic_Syllabic_Category=Vowel_Dependent}

For example, the Sinhala word for the country 'Sri Lanka' isshown in the first row ofFigure 4, which uses both a spacecharacter and a ZWJ. Removing the space results in the text shown inthe second row ofFigure 4, which is still legible, butremoving the ZWJ completely modifies the appearance of the'Sri' cluster and results in the unacceptable text appearanceshown in the third row ofFigure 4.

Figure 4.Sinhala Example withZWJ

AppearanceCode PointsAbbreviated Names
 diagram5 0DC1 + 0DCA + 200D + 0DBB +0DD3 + 0020 + 0DBD + 0D82 + 0D9A + 0DCFSHA + VIRAMA + ZWJ + RA + VOWELSIGN II + SPACE + LA + ANUSVARA + KA + VOWEL SIGN AA
 diagram6 0DC1 + 0DCA + 200D + 0DBB +0DD3 + 0DBD + 0D82 + 0D9A + 0DCFSHA + VIRAMA + ZWJ + RA + VOWELSIGN II + LA + ANUSVARA + KA + VOWEL SIGN AA
 diagram7 0DC1 + 0DCA + 0DBB + 0DD3 +0020 + 0DBD + 0D82 + 0D9A + 0DCFSHA + VIRAMA + RA + VOWEL SIGNII + SPACE + LA + ANUSVARA + KA + VOWEL SIGN AA

Implementations that allow emoji characters in identifiers should also normally allow emoji sequences. These are defined inED-17, emoji sequence in [UTS51]. In particular, that means allowing ZWJ characters, emoji presentation selector (U+FE0F), and TAG characters, but only in the particular defined contexts described in [UTS51].

2.3.1Limitations

While the restrictions inA1,A2, andB greatlylimit visual confusability, they do not prevent it. For example,because Tamil only uses a Join_Control character in one specificcase, most of the sequences these rules allow in Tamil are, in fact,visually confusable. Therefore based on their knowledge of the scriptconcerned, implementations may choose to have tighter restrictionsthan specified below. There are also cases where a joiner preceding avirama makes a visual distinction in some scripts. It is currentlyunclear whether this distinction is important enough in identifiersto warrant retention of a joiner. For more information, see UTR #36:Unicode Security Considerations [UTR36].

Performance. Parsing identifiers can be aperformance-sensitive task. However, these characters are quite rarein practice, thus the regular expressions (or equivalent processing)only rarely would need to be invoked. Thus these tests should not addany significant performance cost overall.

Comparison. Typically the identifiers with andwithout these characters should compare as equivalent, to preventsecurity issues. SeeSection 2.4,Specific CharacterAdjustments.

2.4Specific CharacterAdjustments

Specific identifier syntaxes can be treated as tailorings (orprofiles)of the generic syntax based on character properties. For example, SQLidentifiers allow an underscore as an identifier continue, but not asan identifier start; C identifiers allow an underscore as either anidentifier continue or an identifier start. Specific languages mayalso want to exclude the characters that have a Decomposition_Typeother than Canonical or None, or to exclude some subset of those,such as those with a Decomposition_Type equal to Font.

There are circumstances in which identifiers are expected to morefully encompass words or phrases used in natural languages. Forexample, it is recommended that U+00B7 (·) MIDDLE DOT be allowed inmedial positions in natural-language identifiers such as hashtags orsearch terms, because it is required for grammatical Catalan. For related issues about MIDDLE DOT, seeSection 5,Normalization and Case.

For more natural-language identifiers, a profile should allow thecharacters inTable 3,Table3a, andTable 3b inidentifiers, unless there are compelling reasons not to. Most additions to identifiers are restrictedto medial positions, such as U+00B7 ( · ) MIDDLE DOT, which is not needed as atrailing character in Catalan. These are listed inTable 3a. A few characters canalso occur in final positions, and are listed inTable 3b. The contents of thesetables may overlap.

In some environments even spaces and @are allowed in identifiers, such as in SQL:SELECT * FROMEmployee Pension.

Table 3.Optional Characters for Start

Code PointCharacterName
0024$DOLLAR SIGN
005F_LOW LINE

Table 3a.Optional Characters for Medial

Code PointCharacterName
0027'APOSTROPHE
002D-HYPHEN-MINUS
002E.FULL STOP
003A:COLON
00B7·MIDDLE DOT
058A֊ARMENIAN HYPHEN
05F4״HEBREW PUNCTUATION GERSHAYIM
0F0BTIBETAN MARK INTERSYLLABIC TSHEG
200C\u200CZERO WIDTH NON-JOINER*
2010HYPHEN
2019RIGHT SINGLE QUOTATION MARK
2027HYPHENATION POINT
30A0KATAKANA-HIRAGANA DOUBLE HYPHEN
30FBKATAKANA MIDDLE DOT

Table 3b.Optional Characters forContinue

Code PointCharacterName
05F3׳HEBREW PUNCTUATION GERESH
200D\u200DZERO WIDTH JOINER*

The characters marked with an asterisk inTable3a andTable 3b are Join_Control characters, discussed inSection 2.3,Layout and FormatControl Characters.

In UnicodeSet syntax, the characters in these tables are:

In identifiers that allow for unnormalized characters, thecompatibility equivalents of the characters listed inTable 3,Table 3a, andTable 3bmay also be appropriate.

For more information on characters that may occur in words, and thosethat may be used in name validation, see Section 4, Word Boundaries, in [UAX29].

Some characters are not in modern customary use, and thusimplementations may want to exclude them from identifiers. Theseinclude characters in historic and obsolete scripts, scripts usedmostly liturgically, and regional scripts used only in very smallcommunities or with very limited current usage. Some scripts also have unresolved architectural issues that make them currently unsuitable for identifiers. The set of charactersinTable 4,Candidate Characters for Exclusion from Identifiers providescandidates of these, plus some inappropriate technical blocks.

Table 4.Candidate Characters for Exclusion from Identifiers

Property NotationDescription
\p{script=Aghb}Caucasian Albanian
\p{script=Ahom}Ahom
\p{script=Armi}Imperial Aramaic
\p{script=Avst}Avestan
\p{script=Bass}Bassa Vah
\p{script=Bhks}Bhaiksuki
\p{script=Brah}Brahmi
\p{script=Bugi}Buginese
\p{script=Buhd}Buhid
\p{script=Cari}Carian
\p{script=Copt}Coptic
\p{script=Cprt}Cypriot
\p{script=Dogr}Dogra
\p{script=Dsrt}Deseret
\p{script=Dupl}Duployan
\p{script=Egyp}Egyptian Hieroglyphs
\p{script=Elba}Elbasan
\p{script=Glag}Glagolitic
\p{script=Gong}Gunjala Gondi
\p{script=Gonm}Masaram Gondi
\p{script=Goth}Gothic
\p{script=Gran}Grantha
\p{script=Hano}Hanunoo
\p{script=Hatr}Hatran
\p{script=Hluw}Anatolian Hieroglyphs
\p{script=Hmng}Pahawh Hmong
\p{script=Hung}Old Hungarian
\p{script=Ital}Old Italic
\p{script=Khar}Kharoshthi
\p{script=Khoj}Khojki
\p{script=Kthi}Kaithi
\p{script=Lina}Linear A
\p{script=Linb}Linear B
\p{script=Lyci}Lycian
\p{script=Lydi}Lydian
\p{script=Maka}Makasar
\p{script=Mahj}Mahajani
\p{script=Mani}Manichaean
\p{script=Marc}Marchen
\p{script=Medf}Medefaidrin
\p{script=Mend}Mende Kikakui
\p{script=Mero}Meroitic Hieroglyphs
\p{script=Merc}Meroitic Cursive
\p{script=Modi}Modi
\p{script=Mong}Mongolian
\p{script=Mroo}Mro
\p{script=Mult}Multani
\p{script=Narb}Old North Arabian
\p{script=Nbat}Nabataean
\p{script=Nshu}Nushu
\p{script=Ogam}Ogham
\p{script=Orkh}Old Turkic
\p{script=Osma}Osmanya
\p{script=Palm}Palmyrene
\p{script=Pauc}Pau Cin Hau
\p{script=Perm}Old Permic
\p{script=Phag}Phags Pa
\p{script=Phlp}Psalter Pahlavi
\p{script=Phli}Inscriptional Pahlavi
\p{script=Phnx}Phoenician
\p{script=Prti}Inscriptional Parthian
\p{script=Rjng}Rejang
\p{script=Runr}Runic
\p{script=Samr}Samaritan
\p{script=Sarb}Old South Arabian
\p{script=Sgnw}SignWriting
\p{script=Shrd}Sharada
\p{script=Shaw}Shavian
\p{script=Sidd}Siddham
\p{script=Sind}Khudawadi
\p{script=Sogd}Sogdian
\p{script=Sogo}Old Sogdian
\p{script=Sora}Sora Sompeng
\p{script=Soyo}Soyombo
\p{script=Tagb}Tagbanwa
\p{script=Tglg}Tagalog
\p{script=Tang}Tangut
\p{script=Takr}Takri
\p{script=Tirh}Tirhuta
\p{script=Ugar}Ugaritic
\p{script=Wara}Warang Citi
\p{script=Xpeo}Old Persian
\p{script=Xsux}Cuneiform
\p{script=Zanb}Zanabazar Square
[\p{Extender=True} &
\p{Joining_Type=Join_Causing}]
0640 ( ‎ـ‎ ) ARABIC TATWEEL
07FA ( ‎ߺ‎ ) NKOLAJANYALAN
\p{Default_Ignorable_Code_Point}Default Ignorable Code Points
SeeSection2.3,Layoutand Format Control Characters
\p{block=Combining_Diacritical_Marks_for_Symbols}
\p{block=Musical_Symbols}
\p{block=Ancient_Greek_Musical_Notation}
\p{block=Phaistos_Disc}

The scripts listed inTable 5,Recommended Scripts are generally recommended for use inidentifiers. These are in widespread modern customary use, or areregional scripts in modern customary use by large communities.

Table 5.Recommended Scripts

Property NotationDescription
\p{script=Zyyy}Common
\p{script=Zinh}Inherited
\p{script=Arab}Arabic
\p{script=Armn}Armenian
\p{script=Beng}Bengali
\p{script=Bopo}Bopomofo
\p{script=Cyrl}Cyrillic
\p{script=Deva}Devanagari
\p{script=Ethi}Ethiopic
\p{script=Geor}Georgian
\p{script=Grek}Greek
\p{script=Gujr}Gujarati
\p{script=Guru}Gurmukhi
\p{script=Hani}Han
\p{script=Hang}Hangul
\p{script=Hebr}Hebrew
\p{script=Hira}Hiragana
\p{script=Knda}Kannada
\p{script=Kana}Katakana
\p{script=Khmr}Khmer
\p{script=Laoo}Lao
\p{script=Latn}Latin
\p{script=Mlym}Malayalam
\p{script=Mymr}Myanmar
\p{script=Orya}Oriya
\p{script=Sinh}Sinhala
\p{script=Taml}Tamil
\p{script=Telu}Telugu
\p{script=Thaa}Thaana
\p{script=Thai}Thai
\p{script=Tibt}Tibetan

As of Unicode 10.0, there is no longer a distinction between aspirational use and limited use scripts, as this has not proven to be productive for the derivation of identifier-related classes used in security profiles. (SeeUTS #39, Unicode Security Mechanisms [UTS39].) Thus the Aspirational scriptsinTable 6,Aspirational Use Scripts have been recategorized as Limited Use and moved toTable 7,Limited Use Scripts.

Table 6. Aspirational Use Scripts (Withdrawn)

Property NotationDescription
intentionally blank

Modern scripts that are in more limited use are listed inTable 7,Limited Use Scripts.To avoid security issues, some implementations may wish to disallowthe limited-use scripts in identifiers. For more information onusage, see the Unicode Locale project [CLDR].

Table 7.Limited Use Scripts

Property NotationDescription
\p{script=Adlm}Adlam
\p{script=Bali}Balinese
\p{script=Bamu}Bamum
\p{script=Batk}Batak
\p{script=Cakm}Chakma
\p{script=Cans}Canadian_Aboriginal
\p{script=Cham}Cham
\p{script=Cher}Cherokee
\p{script=Java}Javanese
\p{script=Kali}Kayah_Li
\p{script=Lana}Tai Tham
\p{script=Lepc}Lepcha
\p{script=Limb}Limbu
\p{script=Lisu}Lisu
\p{script=Mand}Mandaic
\p{script=Mtei}Meetei Mayek
\p{script=Newa}Newa
\p{script=Nkoo}Nko
\p{script=Olck}Ol Chiki
\p{script=Osge}Osage
\p{script=Plrd}Miao
\p{script=Rohg}Hanifi Rohingya
\p{script=Saur}Saurashtra
\p{script=Sund}Sundanese
\p{script=Sylo}Syloti_Nagri
\p{script=Syrc}Syriac
\p{script=Tale}Tai Le
\p{script=Talu}New Tai Lue
\p{script=Tavt}Tai Viet
\p{script=Tfng}Tifinagh
\p{script=Vaii}Vai
\p{script=Yiii}Yi

This is the recommendation as of the current version of Unicode; asnew scripts are added to future versions of Unicode, characters and scripts maybe added to Tables4,5, and7. Characters may also bemoved from one table to another as more information becomesavailable.

There are a few special cases:

For programming language identifiers, normalization and case have anumber of important implications. For a discussion of these issues,seeSection 5,Normalizationand Case.

2.5BackwardCompatibility

Unicode General_Category values are kept as stable as possible, butthey can change across versions of the Unicode Standard. The bulk ofthe characters having a given value are determined by otherproperties, and the coverage expands in the future according to theassignment of those properties. In addition, the Other_ID_Startproperty provides a small list of characters that qualified asID_Start characters in some previous version of Unicode solely on thebasis of their General_Category properties, but that no longerqualify in the current version. These are calledgrandfatheredcharacters.

The Other_ID_Start property includes characters such as thefollowing:

U+2118 ( ℘ ) SCRIPT CAPITAL P
U+212E ( ℮ ) ESTIMATED SYMBOL
U+309B ( ゛ ) KATAKANA-HIRAGANA VOICED SOUND MARK
U+309C ( ゜) KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK

Similarly, the Other_ID_Continue property adds a small list ofcharacters that qualified as ID_Continue characters in some previousversion of Unicode solely on the basis of their General_Categoryproperties, but that no longer qualify in the current version.

The Other_ID_Continue property includes characters such as thefollowing:

U+1369 ETHIOPIC DIGIT ONE...U+1371 ETHIOPIC DIGIT NINE
U+00B7 ( · ) MIDDLE DOT
U+0387 ( · ) GREEK ANO TELEIA
U+19DA ( ᧚ ) NEW TAI LUE THAM DIGIT ONE

The exact list of characters covered by the Other_ID_Start andOther_ID_Continue properties depends on the version of Unicode. Formore information, see Unicode Standard Annex #44, “Unicode CharacterDatabase” [UAX44].

The Other_ID_Start and Other_ID_Continue properties are thusdesigned to ensure that the Unicode identifier specification isbackward compatible. Any sequence of characters that qualified as anidentifier in some version of Unicode will continue to qualify as anidentifier in future versions.

If a specification tailors the Unicode recommendations foridentifiers, then this technique can also be used to maintainbackwards compatibility across versions.

3Immutable Identifiers

The disadvantage of working with the lexical classes definedpreviously is the storage space needed for the detailed definitions,plus the fact that with each new version of the Unicode Standard newcharacters are added, which an existing parser would not be able torecognize. In other words, the recommendations based on that tableare not upwardly compatible.

This problem can be addressed by turning the question around.Instead of defining the set of code points that are allowed, define asmall, fixed set of code points that are reserved for syntactic useand allow everything else (including unassigned code points) as partof an identifier. All parsers written to this specification wouldbehave the same way for all versions of the Unicode Standard, becausethe classification of code points is fixed forever.

The drawback of this method is that it allows “nonsense” to be partof identifiers because the concerns of lexical classification and ofhuman intelligibility are separated. Human intelligibility can,however, be addressed by other means, such as usage guidelines thatencourage a restriction to meaningful terms for identifiers. For anexample of such guidelines, see the XML specification by the W3C,Version 1.0 5th Edition or later [XML].

By increasing the set of disallowed characters, a reasonablyintuitive recommendation for identifiers can be achieved. Thisapproach uses the full specification of identifier classes, as of aparticular version of the Unicode Standard, and permanently disallowsany characters not recommended in that version for inclusion inidentifiers. All code points unassigned as of that version would beallowed in identifiers, so that any future additions to the standardwould already be accounted for. This approach ensures both upwardlycompatible identifier stability and a reasonable division ofcharacters into those that do and do not make human sense as part ofidentifiers.

With or without such fine-tuning, such a compromise approachstill incurs the expense of implementing large lists of code points.While they no longer change over time, it is a matter of choicewhether the benefit of enforcing somewhat word-like identifiersjustifies their cost.

Alternatively, one can use the properties described below andallow all sequences of characters to be identifiers that are neitherPattern_Syntax nor Pattern_White_Space. This has the advantage ofsimplicity and small tables, but allows many more “unnatural”identifiers.

UAX31-R2.Immutable Identifiers: To meet this requirement,an implementation shall define identifiers to be any non-emptystring of characters that contains no character having any of thefollowing property values:

Alternatively, it shall declare that it uses aprofileand define that profile with a precise specification of thecharacters that are added to or removed from the sets of code pointsdefined by these properties.

In its profile, a specification can define identifiers to bemore in accordance with the Unicode identifier definitions at thetime the profile is adopted, while still allowing for strictimmutability. For example, an implementation adopting a profile aftera particular version of Unicode is released (such as Unicode 5.0)could define the profile as follows:

  1. All characters satisfyingUAX31-R1Default Identifiers according to Unicode 5.0
  2. Plus all code points unassigned in Unicode 5.0 that do nothave the property values specified inUAX31-R2 Immutable Identifiers.

This technique allows identifiers to have a more naturalformat—excluding symbols and punctuation already defined—yet alsoprovides absolute code point immutability.

Immutable identifiers are intended for those cases (like XML) that cannot update across versions of Unicode, and do not require information about normalization form, or properties such as General_Category and Script. Immutable identifers that allowunassigned characters cannot provide for normalization formsor these properties, which means that they:

For best practice, a profile disallowing unassigned characters should be provided where possible.

Specifications should also include guidelines and recommendations forthose creating new identifiers. AlthoughUAX31-R2 Immutable Identifiers permits a wide range ofcharacters, as a best practice identifiers should be in the formatNFKC, without using any unassigned characters. For more informationon NFKC, see Unicode Standard Annex #15, “Unicode NormalizationForms” [UAX15].

4Pattern Syntax

There are many circumstances where software interprets patternsthat are a mixture of literal characters, whitespace, and syntaxcharacters. Examples include regular expressions, Java collationrules, Excel or ICU number formats, and many others. In the past,regular expressions and other formal languages have been forced touse clumsy combinations of ASCII characters for their syntax. AsUnicode becomes ubiquitous, some of these will start to use non-ASCIIcharacters for their syntax: first as more readable optionalalternatives, then eventually as the standard syntax.

For forward and backward compatibility, it is advantageous to have afixed set of whitespace and syntax code points for use in patterns.This follows the recommendations that the Unicode Consortium has maderegarding completely stable identifiers, and the practice that isseen in XML 1.0, 5th Edition or later [XML]. (In particular, theUnicode Consortium is committed to not allocating characters suitablefor identifiers in the range U+2190..U+2BFF, which is being used byXML 1.0, 5th Edition.)

With a fixed set of whitespace and syntax code points, apattern language can then have a policy requiring all possible syntaxcharacters (even ones currently unused) to be quoted if they areliterals. Using this policy preserves the freedom to extend thesyntax in the future by using those characters. Past patterns onfuture systems will always work; future patterns on past systems willsignal an error instead of silently producing the wrong results.Consider the following scenario, for example.

In version 1.0 of program X, '≈' is a reserved syntaxcharacter; that is, it does not perform an operation, and it needsto be quoted. In this example, '\'quotes the nextcharacter; that is, it causes it to be treated as a literal insteadof a syntax character. In version 2.0 of program X, '≈' isgiven a real meaning—for example, “uppercase the subsequentcharacters”.

As of Unicode 4.1, two Unicode character properties are definedto provide for stable syntax: Pattern_White_Space andPattern_Syntax.  Particular pattern languages may, of course,override these recommendations, for example, by adding or removingother characters for compatibility with ASCII usage.

For stability, the values of these properties are absolutelyinvariant, not changing with successive versions of Unicode. Ofcourse, this does not limit the ability of the Unicode Standard toencode more symbol or whitespace characters, but the syntax andwhitespace code points recommended for use in patterns will notchange.

Whengenerating rules or patterns, all whitespace and syntaxcode points that are to be literals require quoting, using whateverquoting mechanism is available. For readability, it is recommendedpractice to quote or escape all literal whitespace and defaultignorable code points as well.

Consider the following example, where the items in anglebrackets indicate literal characters:

a<SPACE>b → x<ZERO WIDTH SPACE>y  +z;

Because <SPACE> is a Pattern_White_Space character, itrequires quoting. Because <ZERO WIDTH SPACE> is a defaultignorable character, it should also be quoted for readability. So inthis example, if \uXXXX is used for a code point literal, but isresolved before quoting, and if single quotes are used for quoting,this example might be expressed as:

'a\u0020b' → 'x\u200By' + z;

UAX31-R3.Pattern_White_Spaceand Pattern_Syntax Characters: To meet this requirement, animplementation shall use Pattern_White_Space characters as all andonly those characters interpreted as whitespace in parsing, andshall use Pattern_Syntax characters as all and only those characterswith syntactic use.

Alternatively, it shall declare that it uses aprofileand define that profile with a precise specification of thecharacters that are added to or removed from the sets of code pointsdefined by these properties.

Note: When meeting this requirement, all characters exceptthose that have the Pattern_White_Space or Pattern_Syntax propertiesare available for use as identifiers or literals.

5Normalizationand Case

This section discusses issues that must be taken into accountwhen considering normalization and case folding of identifiers inprogramming languages or scripting languages. Using normalizationavoids many problems where apparently identical identifiers are nottreated equivalently. Such problems can appear both duringcompilation and during linking—in particular across differentprogramming languages. To avoid such problems, programming languagescan normalize identifiers before storing or comparing them. Generallyif the programming language has case-sensitive identifiers, thenNormalization Form C is appropriate; whereas, if the programminglanguage has case-insensitive identifiers, then Normalization Form KCis more appropriate.

Implementations that take normalization and case into accounthave two choices: to treat variants as equivalent, or to disallowvariants.

UAX31-R4.EquivalentNormalized Identifiers: To meet this requirement, an implementationshall specify the Normalization Form and shall provide a precisespecification of the characters that are excluded fromnormalization, if any. If the Normalization Form is NFKC, theimplementation shall apply the modifications in Section 5.1,NFKC Modifications, given by theproperties XID_Start and XID_Continue. Except for identifierscontaining excluded characters, any two identifiers that have thesame Normalization Form shall be treated as equivalent by theimplementation.

UAX31-R5.EquivalentCase-Insensitive Identifiers: To meet this requirement, animplementation shall specify either simple or full case folding, andadhere to the Unicode specification for that folding. Any twoidentifiers that have the same case-folded form shall be treated asequivalent by the implementation.

UAX31-R6.FilteredNormalized Identifiers: To meet this requirement, an implementationshall specify the Normalization Form and shall provide a precisespecification of the characters that are excluded fromnormalization, if any. If the Normalization Form is NFKC, theimplementation shall apply the modifications in Section 5.1,NFKC Modifications, given by theproperties XID_Start and XID_Continue. Except for identifierscontaining excluded characters, allowed identifiers must be in thespecified Normalization Form.

Note: For requirement UAX31-R6, filtering involves disallowing anycharacters in the set \p{NFKC_QuickCheck=No}, or equivalently,disallowing \P{isNFKC}.

UAX31-R7.FilteredCase-Insensitive Identifiers: To meet this requirement, animplementation shall specify either simple or full case folding, andadhere to the Unicode specification for that folding. Except foridentifiers containing excluded characters, allowed identifiers mustbe in the specified Normalization Form.

Note: For requirement UAX31-R7 with full case folding, filteringinvolves disallowing any characters in the set \P{isCasefolded}.

As of Unicode 5.2, an additional string transform is available foruse in matching identifiers:toNFKC_Casefold(S). SeeUAX31-R5 inSection 3.13, Default Case Algorithms in[Unicode]. That operationcase folds and normalizes a string, and also removes defaultignorable code points. It can be used to support an implementation ofEquivalent Case and Compatibility-Insensitive Identifiers.There is a corresponding boolean property,Changes_When_NFKC_Casefolded, which can be used to support animplementation ofFiltered Case and Compatibility-InsensitiveIdentifiers. The NFKC_Casefold character mapping property and theChanges_When_NFKC_Casefolded property are described in UnicodeStandard Annex #44, "Unicode Character Database" [UAX44].

Note: In mathematically oriented programming languages thatmake distinctive use of the Mathematical Alphanumeric Symbols, suchas U+1D400 MATHEMATICAL BOLD CAPITAL A, an application of NFKC mustfilter characters to exclude characters with the property valueDecomposition_Type=Font.

5.1NFKCModifications

Where programming languages are using NFKC to fold differencesbetween characters, they need the following modifications of theidentifier syntax from the Unicode Standard to deal with theidiosyncrasies of a small number of characters. These modificationsare reflected in the XID_Start and XID_Continue properties.

5.1.1Modifications for Characters that Behave Like Combining Marks

Certain characters are not formally combining characters,although they behave in most respects as if they were. In most cases,the mismatch does not cause a problem, but when these characters havecompatibility decompositions, they can cause identifiers not to beclosed under Normalization Form KC. In particular, the following fourcharacters are included in XID_Continue and not XID_Start:

5.1.2Modifications for Irregularly Decomposing Characters

U+037A GREEK YPOGEGRAMMENI and certain Arabic presentationforms have irregular compatibility decompositions and are excludedfrom both XID_Start and XID_Continue. It is recommended that allArabic presentation forms be excluded from identifiers in any event,although only a few of them must be excluded for normalization toguarantee identifier closure.

5.1.3Identifier Closure Under Normalization

With these amendments to the identifier syntax, all identifiers areclosed under all four Normalization Forms. This means that for anystring S, the implications shown inFigure 5 hold.

Figure 5.Normalization Closure

isIdentifier(S) → isIdentifier(toNFD(S))
isIdentifier(toNFC(S))
isIdentifier(toNFKD(S))
isIdentifier(toNFKC(S))

Identifiers are also closed under case operations. For any string S(with exceptions involving a single character), the implicationsshown inFigure 6 hold.

Figure 6.Case Closure

isIdentifier(S) → isIdentifier(toLowercase(S))
isIdentifier(toUppercase(S))
isIdentifier(toFoldedcase(S))

The one exception for casing is U+0345 COMBINING GREEKYPOGEGRAMMENI. In the very unusual case that U+0345 is at the startof S, U+0345 is not in XID_Start, but its uppercase and case-foldedversions are. In practice, this is not a problem because of the waynormalization is used with identifiers.

The reverse implication is true for canonical equivalence butnottrue in the case of compatibility equivalence:

Figure 7.ReverseNormalization Closure

isIdentifier(toNFD(S))
isIdentifier(toNFC(S))
 → isIdentifier(S)
isIdentifier(toNFKD(S))
isIdentifier(toNFKC(S))
 
 ↛ isIdentifier(S)

There are many characters for which the reverse implication is nottrue for compatibility equivalence, because there are many characterscounting as symbols or non-decimal numbers—and thus outside ofidentifiers—whose compatibility equivalents are letters or decimalnumbers and thus in identifiers. Some examples are shown inTable8.

Table 8.Compatibility Equivalents to Letters or Decimal Numbers

Code PointsGCSamplesNames
2070NoSUPERSCRIPT ZERO
20A8ScRUPEE SIGN
2116SoNUMERO SIGN
2120..2122So℠..™SERVICE MARK..TRADE MARK SIGN
2460..2473No①..⑳CIRCLED DIGIT ONE..CIRCLED NUMBER TWENTY
3300..33A6So㌀..㎦SQUARE APAATO..SQUARE KM CUBED

If an implementation needs to ensure both directions forcompatibility equivalence of identifiers, then the identifierdefinition needs to be tailored to add these characters.

For canonical equivalence the implication is true in both directions.isIdentifier(toNFC(S))if and only ifisIdentifier(S).

There were two exceptions before Unicode 5.1, as shown inTable9. If an implementation needs to ensure full canonical equivalenceof identifiers, then the identifier definition must be tailored sothat these characters have the same value, so that either bothisIdentifier(S) and isIdentifier(toNFC(S)) are true, or so that bothvalues are false.

Table 9.Canonical Equivalence Exceptions Prior to Unicode 5.1

isIdentifier(toNFC(S))=TrueisIdentifier(S)=FalseDifferent in
02B9 ( ʹ ) MODIFIER LETTER PRIME0374 ( ʹ ) GREEK NUMERAL SIGNXID and ID
00B7 ( · ) MIDDLE DOT0387 ( · ) GREEK ANO TELEIAXID alone

Those programming languages with case-insensitive identifiers shoulduse the case foldings described inSection 3.13, Default CaseAlgorithms, of [Unicode]to produce a case-insensitive normalized form.

When source text is parsed for identifiers, the folding ofdistinctions (using case mapping or NFKC) must be delayed until afterparsing has located the identifiers. Thus such folding ofdistinctions should not be applied to string literals or to commentsin program source text.

The Unicode Standard supports case folding with normalization, withthe function toNFKC_Casefold(X). See definition UAX31-R5 inSection3.13, Default Case Algorithms in [Unicode] for thespecification of this function and further explanation of its use.

5.2Caseand Stability

The alphabetic case of the initial character of an identifieris used as a mechanism to distinguish syntactic classes in somelanguages like Prolog, Erlang, Haskell, Clean, and Go. For example,in Prolog and Erlang, variables must begin with capital letters (orunderscores) and atoms must not. There are some complications in theuse of this mechanism.

For such a casing distinction in a programming language to workwith unicameral writing systems (such as Kanji or Devanagari),another mechanism (such as underscores) needs to substitute for thecasing distinction.

Casing stability is also an issue for bicameral writing systems. Theassignment of General_Category property values, such as gc=Lu, is notguaranteed to be stable, nor is the assignment of characters to thebroader properties such as Uppercase. So these property values cannotbe used by themselves, without incorporating a grandfatheringmechanism, such as is done for Unicode identifiers inSection2.5Backward Compatibility. That is, the implementation would maintain its own list of specialinclusions and exclusions that require updating for each new versionof Unicode.

Alternatively, a programming language specification can use theoperation specified inCaseFolding Stability as the basis for its casing distinction. Thatoperationis guaranteed to be stable. That is, one can use acasing distinction such as the following:

  1. S is avariable if S begins with anunderscore.
  2. Otherwise, produce S' = toCasefold(toNFKC(S))
    1. S is avariable if firstCodePoint(S) ≠firstCodePoint(S'),
    2. otherwise S is anatom.

This test can clearly be optimized ​for the normal cases, suchas initial ASCII. It is also recommended that identifiers be in NFKCformat, which makes the detection even simpler.

5.2.1EdgeCases for Folding

In Unicode 8.0, the Cherokee script letters have been changedfrom gc=Lo to gc=Lu, and corresponding lowercase letters (gc=Ll) havebeen added. This is an unusual pattern; typically when case pairs areadded, existing letters are changed from gc=Lo to gc=Ll, and newcorresponding uppercase letters (gc=Lu) are added. In the case ofCherokee, it was felt that this solution provided the mostcompatibility for existing implementations in terms of fonttreatment.

The downside of this approach is that the Cherokee characters,when case-folded, will convert as necessary to the pre-8.0characters, namely to the uppercase versions. This folding is unlikethat of any other case-mapped characters in Unicode. Thus thecase-folded version of a Cherokee string will contain uppercaseletters instead of lowercase letters. Compatibility with fonts forthe current user community was felt to be more important than theconfusion introduced by this edge case of case folding, becauseCherokee programmatic identifiers would be rare.

The upshot is that when it comes to identifiers,implementations should never use the General_Category or Lowercase orUppercase properties to test for casing conditions, nor usetoUppercase(), toLowercase(), or toTitlecase() to fold or testidentifiers. Instead, they should instead use Case_Folding orNFKC_CaseFold.

6HashtagIdentifiers

Hashtag identifiers have become very popular insocial media. They consist of a number sign in front of some stringof characters, such as #emoji. The actual composition of allowableUnicode hashtag identifiers varies between vendors. It has alsobecome common for hashtags to include emoji characters, without aclear notion of exactly which characters are included.

This section presents a syntax that can be usedfor parsing Unicode hashtag identifiers for increased interoperability.

UAX31-D2.DefaultHashtag Identifier Syntax:

<Hashtag-Identifier> := <Start> <Continue>* (<Medial> <Continue>+)*

When parsing hashtags in flowing text, it isrecommended that an extended Hashtag only be recognized when thereis no Continue character before a Start character. For example, in“abc#def” there would be no hashtag, while there would be in “abc#def” or “abc.#def”.

UAX31-R8.ExtendedHashtag Identifiers: To meet this requirement, to determine whethera string is a hashtag identifier an implementation shall usedefinitionUAX31-D2, setting:

  1. Start := [#﹟#]
    • U+0023 NUMBER SIGN
    • U+FE5F SMALL NUMBER SIGN
    • U+FF03 FULLWIDTH NUMBER SIGN
    • (These are # and its compatibility equivalents.)
  2. Medial is currently empty, but can be used for customization.
  3. Continue := XID_Continue, plus Emoji, Emoji_Component, and “_”, “-”, “+”, minus Start characters.
    • Note the subtraction of # characters.
    • This is expressed in set notation as:
      [\p{XID_Continue}\p{Extended_Pictographic}\p{Emoji_Component}[-+_]-[#﹟#]]

The Emoji properties are from the corresponding version of [UTS51]. The version of the emoji properties is tied to the version of the Unicode Standard, starting with Version 11.0.

The grandfathering techniques mentioned in Section 2.5Backward Compatibility may beused where stability between successive versions is required.

Comparison and matching should be done after converting to NFKC_CF format. Thus #MötleyCrüe should match #MÖTLEYCRÜEandother variants.

Implementations may choose to add characters inTable 3a,Optional Characters for Medial toMedial andTable 3b,Optional Characters for Continue toContinue for better identifiers for natural languages.

Acknowledgments

Mark Davis is the author of the initial version and has addedto and maintained the text of this annex.

Thanks to Eric Muller, Asmus Freytag, Lisa Moore, Julie Allen, Jonathan Warden, KennethWhistler, and Martin Duerst for feedback on this annex.

References

For references for this annex, see Unicode Standard Annex #41, “Common References for UnicodeStandard Annexes.”

Migration

Version 11.0

Version 11.0 refines the use of ZWJ in identifiers (adding some restrictions and relaxing others slightly), and broadens the definition of hashtag identifiers somewhat. For details, see theModifications.

Version 9.0

In previous versions, the text favored the useof XID_Start and XID_Continue, as in the following paragraph. However, the formal definition used ID_Start and ID_Continue.

The XID_Start and XID_Continue properties are improved lexicalclasses that incorporate the changes described inSection5.1,NFKC Modifications. They are recommended for most purposes, especially for security,over the original ID_Start and ID_Continue properties.

In version 9.0, that is swapped and the X versions arestated explicitly in the formal definition. This affects just thefollowing characters.

037A ; GREEK YPOGEGRAMMENI
0E33 ; THAI CHARACTER SARA AM
0EB3 ; LAO VOWEL SIGN AM
309B ; KATAKANA-HIRAGANA VOICEDSOUND MARK
309C ; KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
FC5E..FC63 ; ARABIC LIGATURE SHADDA WITH SUPERSCRIPT ALEF ISOLATEDFORM
FDFA ; ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM
FDFB ; ARABIC LIGATURE JALLAJALALOUHOU
FE70 ; ARABICFATHATAN ISOLATED FORM
FE72 ; ARABIC DAMMATAN ISOLATEDFORM
FE74 ; ARABIC KASRATAN ISOLATED FORM
FE76 ;ARABIC FATHA ISOLATED FORM
FE78 ; ARABIC DAMMA ISOLATEDFORM
FE7A ; ARABIC KASRA ISOLATED FORM
FE7C ;ARABIC SHADDA ISOLATED FORM
FE7E ; ARABIC SUKUN ISOLATEDFORM
FF9E ; HALFWIDTH KATAKANA VOICED SOUND MARK
FF9F ; HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK

Implementations that wish to maintainconformance to the older recommendation need only declare a profilethat uses ID_Start and ID_Continue instead of XID_Start and XID_Continue.

Version 9.0 splits the older Table 3 from Version 8.0 into 3parts.

Current TablesUnicode 8.0
Table 3,Optional Characters for StartTable 3, Candidate Characters for Inclusion in ID_Continue
Table 3a,Optional Characters for Medial
Table 3b,Optional Characters for Continueonly outlined in text

Version 6.1

Between Unicode Versions 5.2, 6.0 and 6.1, Table 5 was split inthree. In Version 6.1, the resulting tables were renumbered foreasier reference. The titles and links remain the same, forstability.

The following shows the correspondences:

Current TablesUnicode 6.0Unicode 5.2
Table 5,Recommended Scripts5a5
Table 6,Aspirational Use Scripts
Table 7,Limited Use Scripts5b
Table 8,Compatibility Equivalents to Letters or Decimal Numbers66
Table 9,Canonical Equivalence Exceptions Prior to Unicode 5.177

Modifications

The following summarizes modifications from the previously published versionof this annex.

Revision 29

Revision 28 being a proposed update, only changes between revisions 27 and 29 are noted here.

Modifications for previous versions are listed in those respective versions.


© 2018 Unicode®, Inc. All Rights Reserved. TheUnicode Consortium makes no expressed or implied warranty of anykind, and assumes no liability for errors or omissions. No liabilityis assumed for incidental and consequential damages in connectionwith or arising out of the use of the information or programscontained or accompanying this technical report. The UnicodeTerms of Use apply.

Unicode and the Unicode logo are trademarksof Unicode, Inc., and are registered in some jurisdictions.


[8]ページ先頭

©2009-2025 Movatter.jp