HTML5.2の見出し毎の内容を雑にまとめる、2.3. Case-sensitivity and string comparison (大文字と小文字及び文字列の比較)

2. Common infrastructure (共通基盤) の中の 2.3. Case-sensitivity and string comparison (大文字と小文字及び文字列の比較) について

仕様の範囲は短めですが、compatibility caseless が理解できずかなりの時間を費やしています

そしても結局理解できていません


内容についてはあくまで初学者の覚書ですので、正式な仕様はW3CのHTML5.2を確認してください

また、勉強のため、各仕様の邦訳文書、解説文書を読まずに自分で翻訳して覚書を書き終わってから答え合わせとして邦訳文書を参照するようにしています

このため、多くの訳語が一般的な訳と異なっていますのでご注意ください


2.3. Case-sensitivity and string comparison (大文字と小文字及び文字列の比較)

大文字小文字を区別する (case-sensitive) と言うときは厳密に区別し、大文字小文字を区別しない (ASCII case-insensitive) と言うときは大文字小文字以外を厳密に区別しA-Zの大文字小文字は区別しない

互換活字状態を区別しない (compatibility caseless) は、言語固有の調整をしない (no language-specific tailorings) でUnicodeの互換活字状態を区別しない比較(Unicode compatibility caseless match) を行う

特に指定がない場合、大文字小文字は区別する

ほか、大文字小文字の変換方法についてと、パターンマッチが接頭辞一致である事が書いてある


"互換活字状態を区別しない (compatibility caseless)" について

互換活字状態を区別しない (compatibility caseless) は以下の通りに説明されている

Comparing two strings in a compatibility caseless manner means using the Unicode compatibility caseless match operation to compare the two strings, with no language-specific tailorings. [UNICODE]

木俣の直訳は以下の通り

2つの文字列を互換活字状態を区別しない (compatibility caseless) で比較するとは、言語固有の調整をしない (no language-specific tailorings) でUnicodeの互換活字状態を区別しない比較 (Unicode compatibility caseless match) を行う事を意味する

なるほど、さっぱりわからん

で、調べた結果、おそらく言語特性による上位プロトコルのカスタマイズがされていない、つまり、Unicodeのデフォルトのアルゴリズムで、UnicodeCharacter Names Listで等価とされる文字を一致とする比較を行う意味であろうと思われる

以下、Unicodeの仕様の調査の経緯 (というか、羅列) を書くが、で確証は全くない

  1. Compatibility caselessの意味を調べるためGlossary of Unicode Termsで compatibility を引く

    Compatibility. (1) Consistency with existing practice or preexisting character encoding standards. (2) Characteristic of a normative mapping and form of equivalence specified in Section 3.7. Decomposition.

  2. (2) Section 3.7. Decompositionを更に読む

    Each character has at most one decomposition mapping. The mappings in Section 3.12, Conjoining Jamo Behavior, are canonical mappings. The mappings in the character names list are identified as either canonical or compatibility mappings (see Section 24.1, Character Names List)

  3. Jomoはハングルの音節の関する概念らしいので飛ばして、どうやらmatchingに関係しそうなcompatibility mappingsに関して更にSection 24.1, Character Names Listを読む。

    ここまできてどうやら U+00E5 "å" latin small letter a with ring above は U+0061 "a" latin small letter aとU+030A "̊" combining ring above の合字 "å" に等しいとかそういう話らしいと認識する (ここまで来てあやふやな結論)

  4. 更に no language-specific tailorings の tailorings の意味確認するためGlossary of Unicode Termsで tailoringsを調べると、tailorableがあったのでそちらを参照してみる

    Tailorable. A characteristic of an algorithm for which a higher-level protocol may specify different results than those specified in the algorithm. A tailorable algorithm without actual tailoring is also known as a default algorithm, and the results of an algorithm without tailoring are known as the default results.

  5. 以上により、言語特性による上位プロトコルのカスタマイズがされていない、つまり、Unicodeのデフォルトのアルゴリズムで、UnicodeCharacter Names Listで等価とされる文字を一致とする比較を行うと言う意味であろうと認識した


なお、compatibility caselessの処理は 2.4.9. References (参照) の中で使われている

The rules for parsing a hash-name reference to an element of type type, given a context node scope, are as follows:

  1. If the string being parsed does not contain a U+0023 NUMBER SIGN character, or if the first such character in the string is the last character in the string, then return null and abort these steps.
  2. Let s be the string from the character immediately after the first U+0023 NUMBER SIGN character in the string being parsed up to the end of that string.
  3. Return the first element of type type in tree order in the subtree rooted at scope that has an id attribute whose value is a case-sensitive match for s or a name attribute whose value is a compatibility caseless match for s.

つまり、ハッシュ名参照ではid属性は大文字小文字を区別する (case-sensitive) 文字比較を行うが、name属性は互換活字状態を区別しない (compatibility caseless) 比較である、と

と言う訳で以下のようなHTML断片を用意してFirefoxとEdgeで確認してみた

<div><a href='#å'><code>U+0061</code> "&#x0061;" latin small letter a + <code>U+030A</code> "&#x030A;"</a></div>

<div><a name='å'><code>U+00E5</code> "&#x00E5;" latin small letter a with ring above</a></div>

私の理解通りの実装であれば、U+00E5U+0061U+030Aの合字は同じものと見做されHyperLinkによるジャンプが発生するのだが、少なくともFirefox 58 と Microsoft Edge ではジャンプは発生しなかった

わからない