ロケール等による文字コード判定の補助

ロケールと文字コードの関係表

[37] 文字コードに関係する処理では、ロケール言語とそこから推定される文字コード (の候補群) との対応関係の表が使われることがあります。

ロケール依存の既定の文字コード (Web)

[1] Webページへの navigate における文字コードの判定には色々な手法が組合せられますが、 いずれとも決めかねるとき最終的に利用者ロケールによって決まる既定値たる文字コードが選ばれます。

仕様書

概要

[2] 利用者ロケール利用者がよく見るWebページ自然言語符号化と相関があると考えられるため、 ロケールが使われると説明されています。 >>177

[4] 歴史的にみれば Web はそれぞれの利用者言語に合わせて地域化される形で普及したものであり、 各地で標準的に使われていた文字コードがその地域のデファクト標準として使われ始めました。 Webブラウザーは動作プラットフォームの既定値、すなわち利用者ロケール文字コードをそのまま標準的に使っていました。 Webにおける文字コード

[5] ロケール設定に依存するということは、ロケール設定が違えば文字化けするということです。 もちろんこれは望ましくないことで、著者HTTP charset<meta charset> で明示的に文字コードの指定を行うべきで、 Webブラウザー頻度解析等の手法により可能な限り高精度な文字コードの判定を行うべきです。 ロケール依存の既定値は、それらでどうしても決定できない場合にだけ使われます。 encoding sniffing algorithm

[6] 現在となってはロケール依存の既定値が使わざるを得ない状況はそう多くはないとはいえ、 古い時代に作られたWebサイトを中心に、未だに必要とされています。 今後急激に増える可能性は皆無ですが、 既存の Webサイト (Internet Archive 所蔵のものを含む。) を後世にそのままの形で伝えていくために Webブラウザーは恒久的にロケール依存の既定値に対応し続けなければなりません。


[3] HTML Standard には、策定当時の主要 Webブラウザーの実装状況に基づき決められたロケールと既定の文字符号化の対応表が示されています。 >>177

[7] この既定値は実装依存かつ利用者の指定が可能と規定されており、 HTML Standard に提示された表が1つの基準となるものの、 それが強制されているわけではありません。

[8] 実装は、実際の Webサイトの実情や他の実装の状況を勘案しつつ、 Web互換性を高めるため改善を続けることが期待されます。


[17] HTML Standard の表は直接的には既定値しか定めていませんが、 頻度解析等の手法で重視するべき文字コード群の絞り込みにもロケール情報は有用と考えられます。

[18] 例えばロケールja (日本語) のとき、 Shift_JIS, EUC-JP, ISO-2022-JP を他の文字コードより重視する動作モードで頻度解析等の手法を実行すると良さそうです。

HTML Standard の規定の歴史的変遷

[10] HTML5 (現 HTML Standard) の主要な版の変更点と、 それに関連して当時参照された実装の状況は次の通りです。

l
ロケール
0
HTML5 初期 >>206
a
HTML5 r4126 >>206
vi
Windows Vista >>183
fx
Firefox >>183
ch
Chrome >>183
b
HTML5 r7958 >>183
c
HTML5 r8258 >>184, r8259 >>185
x
HTML Standard >>9
aug
調整
l
af
vi
windows-1252
fx
windows-1252
l
am
vi
windows-1252
ch
windows-1252
l
ar
a
UTF-8
b
windows-1256
vi
windows-1256
ch
windows-1256
x
windows-1256
l
arn-CL
fx
windows-1252
vi
windows-1252
l
az
ch
-
fx
-
vi
windows-1254
x
windows-1254
l
az-Cyrl-AZ
ch
-
fx
-
vi
windows-1251
l
ba
c
windows-1251
x
windows-1251
l
ba-RU
ch
-
fx
-
vi
windows-1251
l
be
a
ISO-8859-5
ch
<none>
vi
windows-1251
fx
ISO-8859-5
c
windows-1251
x
windows-1251
l
be-BY
ch
-
fx
-
vi
windows-1251
l
bg
a
windows-1251
b
windows-1251
ch
windows-1251
fx
windows-1251
vi
windows-1251
x
windows-1251
l
bn
fx
windows-1252
ch
windows-1252
l
br-FR
vi
windows-1252
fx
windows-1252
l
bs-Cyrl-BA
ch
-
fx
-
vi
windows-1251
l
bs-Latn-BA
ch
-
fx
-
vi
windows-1250
l
ca
vi
windows-1252
ch
windows-1252
fx
windows-1252
l
co-FR
vi
windows-1252
fx
windows-1252
l
cs cs-CZ
a
ISO-8859-2
l
cs
b
windows-1250
vi
windows-1250
ch
windows-1250
fx
ISO-8859-2
x
windows-1250
l
cy
a
UTF-8
l
cy-GB
vi
windows-1252
fx
windows-1252
l
da
vi
windows-1252
ch
windows-1252
fx
windows-1252
l
de
vi
windows-1252
ch
windows-1252
fx
windows-1252
l
el
vi
windows-1253
ch
ISO-8859-7
fx
windows-1252 (実際は ISO-8859-7 >>1202)
c
ISO-8859-7
x
ISO-8859-7
l
el-GR
ch
-
fx
-
vi
windows-1253
l
en
vi
windows-1252
fx
windows-1252
l
es
vi
windows-1252
ch
windows-1252
fx
windows-1252
l
et
b
windows-1257
vi
windows-1257
ch
windows-1257
x
windows-1257
l
eu
vi
windows-1252
fx
windows-1252
l
fa (fa-IR)
a
UTF-8
l
fa
b
windows-1256
vi
windows-1256
ch
windows-1256
x
windows-1256
l
fi
vi
windows-1252
ch
windows-1252
fx
windows-1252
l
fil
fx
windows-1252
ch
windows-1252
l
fo
vi
windows-1252
fx
windows-1252
l
fr
vi
windows-1252
ch
windows-1252
fx
windows-1252
l
fy-NL
vi
windows-1252
fx
windows-1252
l
ga-IE
vi
windows-1252
fx
windows-1252
l
gl
vi
windows-1252
fx
windows-1252
l
gsw-FR
vi
windows-1252
fx
windows-1252
l
gu
ch
windows-1252
fx
windows-1252
l
ha-Latn-NG
vi
windows-1252
fx
windows-1252
l
he (he-IL)
a
windows-1255
l
he
b
windows-1255
vi
windows-1255
ch
windows-1255
fx
windows-1255
x
windows-1255
l
hi
ch
windows-1252
fx
windows-1252
l
hr
a
UTF-8
b
windows-1250
vi
windows-1250
ch
windows-1250
x
windows-1250
l
hu (hu-HU)
a
ISO-8859-2
l
hu
b
ISO-8859-2
ch
ISO-8859-2
fx
ISO-8859-2
vi
windows-1250
x
ISO-8859-2
l
hu-HU
ch
-
fx
-
vi
windows-1250
l
id
vi
windows-1252
ch
windows-1252
fx
windows-1252
l
ig-NG
vi
windows-1252
fx
windows-1252
l
is
vi
windows-1252
fx
windows-1252
l
it
vi
windows-1252
ch
windows-1252
fx
windows-1252
l
iu-Latn-CA
vi
windows-1252
fx
windows-1252
l
ja (ja, ja-JP-mac)
a
windows-31J (Shift_JIS)
l
ja
b
Shift_JIS
vi
Shift_JIS
ch
Shift_JIS
fx
Shift_JIS
x
Shift_JIS
l
ka
aug
georgian-ps >>15
l
kk
a
UTF-8
ch
-
fx
-
vi
windows-1251
c
windows-1251
x
windows-1251
l
kl-GL
vi
windows-1252
fx
windows-1252
l
kn
ch
windows-1252
fx
windows-1252
l
ko (ko-KR)
a
windows-949 (EUC-KR)
l
ko
b
windows-949
vi
windows-949
ch
windows-949
fx
windows-949
x
EUC-KR
l
ku
a
windows-1254 (ISO-8859-9)
b
windows-1254 (Best guess)
x
windows-1254
l
ky
ch
-
fx
-
vi
windows-1251
c
windows-1251
x
windows-1251
l
lb-LU
vi
windows-1252
fx
windows-1252
l
lt
a
windows-1257
b
windows-1257
vi
windows-1257
fx
windows-1257
ch
windows-1257
x
windows-1257
l
lv (lv-LV)
a
ISO-8859-13
l
lv
b
windows-1257
vi
windows-1257
ch
windows-1257
fx
ISO-8859-13
x
windows-1257
l
mk (mk-MK)
a
UTF-8
l
mk
ch
-
fx
-
vi
windows-1251
c
windows-1251
x
windows-1251
l
ml
ch
windows-1252
fx
windows-1252
l
mn
ch
-
fx
-
vi
windows-1251
aug
MNS 4330 >>13
l
moh-CA
vi
windows-1252
fx
windows-1252
l
mr
ch
windows-1252
fx
windows-1252
l
ms
vi
windows-1252
fx
windows-1252
l
nb
ch
windows-1252
fx
windows-1252
l
nl
vi
windows-1252
ch
windows-1252
fx
windows-1252
l
nn-NO
vi
windows-1252
fx
windows-1252
l
no
vi
windows-1252
fx
windows-1252
l
nso-ZA
vi
windows-1252
fx
windows-1252
l
oc-FR
vi
windows-1252
fx
windows-1252
l
or
a
UTF-8
l
pl (pl-PL)
a
ISO-8859-2
l
pl
b
ISO-8859-2
ch
ISO-8859-2
fx
ISO-8859-2
vi
windows-1250
x
ISO-8859-2
l
pl-PL
ch
-
fx
-
vi
windows-1250
l
prs-AF
ch
-
fx
-
vi
windows-1256
l
pt
vi
windows-1252
fx
windows-1252
l
qut-GT
vi
windows-1252
fx
windows-1252
l
quz-BO
vi
windows-1252
fx
windows-1252
l
quz-EC
vi
windows-1252
fx
windows-1252
l
quz-PE
vi
windows-1252
fx
windows-1252
l
rm-CH
vi
windows-1252
fx
windows-1252
l
ro
a
UTF-8
vi
windows-1250
ch
ISO-8859-2
fx
<none>
aug
ISO-8859-2 >>14
l
ro-RO
ch
-
fx
-
vi
windows-1250
l
ru
a
windows-1251
b
windows-1251
vi
windows-1251
ch
windows-1251
fx
windows-1251
x
windows-1251
l
rw-RW
vi
windows-1252
fx
windows-1252
l
sah
c
windows-1251
x
windows-1251
l
sah-RU
ch
-
fx
-
vi
windows-1251
l
se-FI
vi
windows-1252
fx
windows-1252
l
se-NO
vi
windows-1252
fx
windows-1252
l
se-SE
vi
windows-1252
fx
windows-1252
l
sk
a
windows-1250
vi
windows-1250
ch
windows-1250
fx
windows-1250
x
windows-1250
l
sl
a
ISO-8859-2
b
ISO-8859-2
ch
ISO-8859-2
fx
ISO-8859-2
vi
windows-1250
x
ISO-8859-2
l
sl-SI
ch
-
fx
-
vi
windows-1250
l
sma-NO
vi
windows-1252
fx
windows-1252
l
sma-SE
vi
windows-1252
fx
windows-1252
l
smj-NO
vi
windows-1252
fx
windows-1252
l
smj-SE
vi
windows-1252
fx
windows-1252
l
smn-FI
vi
windows-1252
fx
windows-1252
l
sms-FI
vi
windows-1252
fx
windows-1252
l
sq
ch
-
fx
-
vi
windows-1250
l
sr
a
UTF-8
b
windows-1251
vi
windows-1251
ch
windows-1251
x
windows-1251
l
sr-Latn-BA
vi
windows-1250
ch
-
fx
-
l
sr-Latn-SP
ch
-
fx
-
vi
windows-1250
l
sv
vi
windows-1252
ch
windows-1252
fx
windows-1252
l
sw
vi
windows-1252
ch
windows-1252
fx
windows-1252
l
ta
ch
windows-1252
fx
windows-1252
l
te
ch
windows-1252
fx
windows-1252
l
tg
c
windows-1251
x
windows-1251
l
tg-Cyrl-TJ
vi
windows-1251
ch
-
fx
-
l
th
a
windows-874 (TIS-620)
b
windows-874
fx
windows-874
ch
windows-874
vi
windows-874
x
windows-874
l
tk-TM
ch
-
fx
-
vi
windows-1250
l
tn-ZA
vi
windows-1252
fx
windows-1252
l
tr (tr-TR)
a
windows-1254 (ISO-8859-9)
l
tr
b
windows-1254
vi
windows-1254
ch
windows-1254
fx
windows-1254
x
windows-1254
l
tt
ch
-
fx
-
vi
windows-1251
c
windows-1251
x
windows-1251
l
tzm-Latn-DZ
vi
windows-1252
fx
windows-1252
l
ug-CN
vi
windows-1256
ch
-
fx
-
l
uk
a
windows-1251
b
windows-1251
vi
windows-1251
ch
windows-1251
fx
windows-1251
x
windows-1251
l
ur
ch
-
fx
-
vi
windows-1256
l
uz
ch
-
fx
-
vi
windows-1254
l
uz-Cyrl-UZ
ch
-
fx
-
vi
windows-1251
l
vi
a
UTF-8
b
windows-1258
ch
windows-1258
vi
windows-1258
x
windows-1258
aug
Windows-1252 >>193
l
wee-DE
vi
windows-1252
fx
windows-1252
l
wen-DE
vi
windows-1252
fx
windows-1252
l
wo-SN
vi
windows-1252
fx
windows-1252
l
xh-ZA
vi
windows-1252
fx
windows-1252
l
yo-NG
vi
windows-1252
fx
windows-1252
l
zh-CN
a
GB18030
b
GB18030
vi
GB18030
ch
GB18030
fx
GB18030
x
GBK
l
zh-HK
ch
-
fx
-
vi
Big5
x
Big5
l
zh-Hans
ch
-
fx
-
vi
GB18030
x
GBK
l
zh-Hant
ch
-
fx
-
vi
Big5
x
Big5
l
zh-MO
ch
-
fx
-
vi
Big5
x
Big5
l
zh-SG
ch
-
fx
-
vi
GB18030
x
GBK
l
zh-TW
a
Big5
b
Big5
vi
Big5
ch
Big5
fx
Big5
x
Big5
l
zu-ZA
vi
windows-1252
fx
windows-1252
l
西洋
0
windows-1252
l
その他
a
windows-1252
b
windows-1252
x
windows-1252

[205] ロケール依存の既定値について、 HTML5 の当初の規定は「主に西洋 (Western) では Windows-1252」というだけしかありませんでした。 >>204

[206] その後 Mozilla 1.9.1 に基づく表に改められました。 >>204

      <tr>
       <td>ar
       <td>UTF-8

      <tr>
       <td>be
       <td>ISO-8859-5

      <tr>
       <td>bg
       <td>windows-1251

      <tr>
       <td>cs<!-- -CZ -->
       <td>ISO-8859-2

      <tr>
       <td>cy
       <td>UTF-8

      <tr>
       <td>fa<!-- -IR -->
       <td>UTF-8

      <tr>
       <td>he<!-- -IL -->
       <td>windows-1255

      <tr>
       <td>hr
       <td>UTF-8

      <tr>
       <td>hu<!-- -HU -->
       <td>ISO-8859-2

      <tr>
       <td>ja <!-- and ja-JP-mac -->
       <td>windows-31J <!-- Shift_JIS -->

      <tr>
       <td>kk
       <td>UTF-8

      <tr>
       <td>ko<!-- -KR -->
       <td>windows-949 <!-- EUC-KR -->

      <tr>
       <td>ku
       <td>windows-1254 <!-- ISO-8859-9 -->

      <tr>
       <td>lt
       <td>windows-1257

      <tr>
       <td>lv<!-- -LV -->
       <td>ISO-8859-13

      <tr>
       <td>mk<!-- -MK -->
       <td>UTF-8

      <tr>
       <td>or
       <td>UTF-8

      <tr>
       <td>pl<!-- -PL -->
       <td>ISO-8859-2

      <tr>
       <td>ro
       <td>UTF-8

      <tr>
       <td>ru
       <td>windows-1251

      <tr>
       <td>sk
       <td>windows-1250

      <tr>
       <td>sl
       <td>ISO-8859-2

      <tr>
       <td>sr
       <td>UTF-8

      <tr>
       <td>th
       <td>windows-874 <!-- TIS-620 -->

      <tr>
       <td>tr<!-- -TR -->
       <td>windows-1254 <!-- ISO-8859-9 -->

      <tr>
       <td>uk
       <td>windows-1251

      <tr>
       <td>vi
       <td>UTF-8

      <tr>
       <td>zh-CN
       <td>GB18030

      <tr>
       <td>zh-TW
       <td>Big5

      <tr>
       <td>All other locales
       <td>windows-1252

[192] 更に当時の Webブラウザーの挙動の調査が進められました。 >>191

Locale     Description     Vista           Chrome          Spec/Firefox
ro         Romanian        windows-1250    ISO-8859-2      windows-1252
cs         Czech           windows-1250    windows-1250    ISO-8859-2
hu         Hungarian       windows-1250    ISO-8859-2      ISO-8859-2
lv         Latvian         windows-1257    windows-1257    ISO-8859-13
sl         Slovenian       windows-1250    ISO-8859-2      ISO-8859-2
pl         Polish          windows-1250    ISO-8859-2      ISO-8859-2
be         Belarusian      windows-1251    <none>          ISO-8859-5
el         Greek           windows-1253    ISO-8859-7      windows-1252

[19] その結果を踏まえた変更の経緯が HTML5 に注釈として記録されています。 >>195

      <!-- af, Afrikaans, uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- am, Amharic, uses windows-1252: Firefox and Chrome agreed -->

      <tr>
       <td>ar
       <td>Arabic
       <td>windows-1256 <!-- Windows Vista and Chrome agreed -->

      <!-- arn-CL, Mapudungun (Chile), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- az, Azeri, is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1254 -->

      <!-- az-Cyrl-AZ, Azeri (Cyrillic, Azerbaijan), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <!-- ba-RU, Bashkir (Russia), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <!-- be, Belarusian, is not listed here because Windows Vista wanted windows-1251, Chrome wanted <none>, and Firefox wanted ISO-8859-5 -->

      <!-- be-BY, Belarusian (Belarus), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <tr>
       <td>bg
       <td>Bulgarian
       <td>windows-1251 <!-- Windows Vista, Chrome, and Firefox agreed -->

      <!-- bn, Bengali, uses windows-1252: Firefox and Chrome agreed -->

      <!-- br-FR, Breton (France), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- bs-Cyrl-BA, Bosnian (Cyrillic, Bosnia and Herzegovina), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <!-- bs-Latn-BA, Bosnian (Latin, Bosnia and Herzegovina), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1250 -->

      <!-- ca, Catalan, uses windows-1252: Windows Vista, Chrome, and Firefox agreed -->

      <!-- co-FR, Corsican (France), uses windows-1252: Windows Vista and Firefox agreed -->

      <tr>
       <td>cs
       <td>Czech
       <td>windows-1250 <!-- Windows Vista and Chrome agreed (but disagreed with Firefox, which thought the encoding should be ISO-8859-2) -->

      <!-- cy-GB, Welsh (United Kingdom), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- da, Danish, uses windows-1252: Windows Vista, Chrome, and Firefox agreed -->

      <!-- de, German, uses windows-1252: Windows Vista, Chrome, and Firefox agreed -->

      <!-- el, Greek, is not listed here because Windows Vista wanted windows-1253, Chrome wanted ISO-8859-7, and Firefox wanted windows-1252 -->

      <!-- el-GR, Greek (Greece), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1253 -->

      <!-- en, English, uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- es, Spanish, uses windows-1252: Windows Vista, Chrome, and Firefox agreed -->

      <tr>
       <td>et
       <td>Estonian
       <td>windows-1257 <!-- Windows Vista and Chrome agreed -->

      <!-- eu, Basque, uses windows-1252: Windows Vista and Firefox agreed -->

      <tr>
       <td>fa
       <td>Persian
       <td>windows-1256 <!-- Windows Vista and Chrome agreed -->

      <!-- fi, Finnish, uses windows-1252: Windows Vista, Chrome, and Firefox agreed -->

      <!-- fil, Filipino, uses windows-1252: Firefox and Chrome agreed -->

      <!-- fo, Faroese, uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- fr, French, uses windows-1252: Windows Vista, Chrome, and Firefox agreed -->

      <!-- fy-NL, Frisian (Netherlands), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- ga-IE, Irish (Ireland), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- gl, Galician, uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- gsw-FR, Alsatian (France), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- gu, Gujarati, uses windows-1252: Firefox and Chrome agreed -->

      <!-- ha-Latn-NG, Hausa (Latin, Nigeria), uses windows-1252: Windows Vista and Firefox agreed -->

      <tr>
       <td>he
       <td>Hebrew
       <td>windows-1255 <!-- Windows Vista, Chrome, and Firefox agreed -->

      <!-- hi, Hindi, uses windows-1252: Firefox and Chrome agreed -->

      <tr>
       <td>hr
       <td>Croatian
       <td>windows-1250 <!-- Windows Vista and Chrome agreed -->

      <tr>
       <td>hu
       <td>Hungarian
       <td>ISO-8859-2 <!-- Chrome and Firefox agreed (but disagreed with Windows Vista, which thought the encoding should be windows-1250) -->

      <!-- hu-HU, Hungarian (Hungary), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1250 -->

      <!-- id, Indonesian, uses windows-1252: Windows Vista, Chrome, and Firefox agreed -->

      <!-- ig-NG, Igbo (Nigeria), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- is, Icelandic, uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- it, Italian, uses windows-1252: Windows Vista, Chrome, and Firefox agreed -->

      <!-- iu-Latn-CA, Inuktitut (Latin, Canada), uses windows-1252: Windows Vista and Firefox agreed -->

      <tr>
       <td>ja
       <td>Japanese
       <td>Shift_JIS <!-- Windows Vista, Chrome, and Firefox agreed -->

      <!-- kk, Kazakh, is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <!-- kl-GL, Greenlandic (Greenland), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- kn, Kannada, uses windows-1252: Firefox and Chrome agreed -->

      <tr>
       <td>ko
       <td>Korean
       <td>windows-949 <!-- Windows Vista, Chrome, and Firefox agreed -->

      <tr>
       <td>ku
       <td>Kurdish
       <td>windows-1254 <!-- Best guess -->

      <!-- ky, Kyrgyz, is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <!-- lb-LU, Luxembourgish (Luxembourg), uses windows-1252: Windows Vista and Firefox agreed -->

      <tr>
       <td>lt
       <td>Lithuanian
       <td>windows-1257 <!-- Windows Vista, Chrome, and Firefox agreed -->

      <tr>
       <td>lv
       <td>Latvian
       <td>windows-1257 <!-- Windows Vista and Chrome agreed (but disagreed with Firefox, which thought the encoding should be ISO-8859-13) -->

      <!-- mk, Macedonian, is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <!-- ml, Malayalam, uses windows-1252: Firefox and Chrome agreed -->

      <!-- mn, Mongolian, is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <!-- moh-CA, Mohawk (Mohawk), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- mr, Marathi, uses windows-1252: Firefox and Chrome agreed -->

      <!-- ms, Malay, uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- nb, Norwegian Bokm&aring;l, uses windows-1252: Firefox and Chrome agreed -->

      <!-- nl, Dutch, uses windows-1252: Windows Vista, Chrome, and Firefox agreed -->

      <!-- nn-NO, Norwegian, Nynorsk (Norway), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- no, Norwegian, uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- nso-ZA, Sesotho sa Leboa (South Africa), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- oc-FR, Occitan (France), uses windows-1252: Windows Vista and Firefox agreed -->

      <tr>
       <td>pl
       <td>Polish
       <td>ISO-8859-2 <!-- Chrome and Firefox agreed (but disagreed with Windows Vista, which thought the encoding should be windows-1250) -->

      <!-- pl-PL, Polish (Poland), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1250 -->

      <!-- prs-AF, Dari (Afghanistan), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1256 -->

      <!-- pt, Portuguese, uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- qut-GT, K'iche (Guatemala), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- quz-BO, Quechua (Bolivia), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- quz-EC, Quechua (Ecuador), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- quz-PE, Quechua (Peru), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- rm-CH, Romansh (Switzerland), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- ro, Romanian, is not listed here because Windows Vista wanted windows-1250, Chrome wanted ISO-8859-2, and Firefox wanted <none> -->

      <!-- ro-RO, Romanian (Romania), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1250 -->

      <tr>
       <td>ru
       <td>Russian
       <td>windows-1251 <!-- Windows Vista, Chrome, and Firefox agreed -->

      <!-- rw-RW, Kinyarwanda (Rwanda), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- sah-RU, Yakut (Russia), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <!-- se-FI, Sami, Northern (Finland), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- se-NO, Sami, Northern (Norway), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- se-SE, Sami, Northern (Sweden), uses windows-1252: Windows Vista and Firefox agreed -->

      <tr>
       <td>sk
       <td>Slovak
       <td>windows-1250 <!-- Windows Vista, Chrome, and Firefox agreed -->

      <tr>
       <td>sl
       <td>Slovenian
       <td>ISO-8859-2 <!-- Chrome and Firefox agreed (but disagreed with Windows Vista, which thought the encoding should be windows-1250) -->

      <!-- sl-SI, Slovenian (Slovenia), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1250 -->

      <!-- sma-NO, Sami, Southern (Norway), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- sma-SE, Sami, Southern (Sweden), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- smj-NO, Sami, Lule (Norway), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- smj-SE, Sami, Lule (Sweden), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- smn-FI, Sami, Inari (Finland), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- sms-FI, Sami, Skolt (Finland), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- sq, Albanian, is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1250 -->

      <tr>
       <td>sr
       <td>Serbian
       <td>windows-1251 <!-- Windows Vista and Chrome agreed -->

      <!-- sr-Latn-BA, Serbian (Latin, Bosnia and Herzegovina), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1250 -->

      <!-- sr-Latn-SP, Serbian (Latin, Serbia), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1250 -->

      <!-- sv, Swedish, uses windows-1252: Windows Vista, Chrome, and Firefox agreed -->

      <!-- sw, Kiswahili, uses windows-1252: Windows Vista, Chrome, and Firefox agreed -->

      <!-- ta, Tamil, uses windows-1252: Firefox and Chrome agreed -->

      <!-- te, Telugu, uses windows-1252: Firefox and Chrome agreed -->

      <!-- tg-Cyrl-TJ, Tajik (Cyrillic, Tajikistan), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <tr>
       <td>th
       <td>Thai
       <td>windows-874 <!-- Windows Vista, Chrome, and Firefox agreed -->

      <!-- tk-TM, Turkmen (Turkmenistan), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1250 -->

      <!-- tn-ZA, Setswana (South Africa), uses windows-1252: Windows Vista and Firefox agreed -->

      <tr>
       <td>tr
       <td>Turkish
       <td>windows-1254 <!-- Windows Vista, Chrome, and Firefox agreed -->

      <!-- tt, Tatar, is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <!-- tzm-Latn-DZ, Tamazight (Latin, Algeria), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- ug-CN, Uighur (PRC), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1256 -->

      <tr>
       <td>uk
       <td>Ukrainian
       <td>windows-1251 <!-- Windows Vista, Chrome, and Firefox agreed -->

      <!-- ur, Urdu, is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1256 -->

      <!-- uz, Uzbek, is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1254 -->

      <!-- uz-Cyrl-UZ, Uzbek (Cyrillic, Uzbekistan), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->

      <tr>
       <td>vi
       <td>Vietnamese
       <td>windows-1258 <!-- Windows Vista and Chrome agreed -->

      <!-- wee-DE, Lower Sorbian (Germany), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- wen-DE, Upper Sorbian (Germany), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- wo-SN, Wolof (Senegal), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- xh-ZA, isiXhosa (South Africa), uses windows-1252: Windows Vista and Firefox agreed -->

      <!-- yo-NG, Yoruba (Nigeria), uses windows-1252: Windows Vista and Firefox agreed -->

      <tr>
       <td>zh-CN
       <td>Chinese (People's Republic of China)
       <td>GB18030 <!-- Windows Vista, Chrome, and Firefox agreed -->

      <!-- zh-HK, Chinese (Hong Kong S.A.R.), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted Big5 -->

      <!-- zh-Hans, Chinese (Simplified), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted GB18030 -->

      <!-- zh-Hant, Chinese (Traditional), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted Big5 -->

      <!-- zh-MO, Chinese (Macao S.A.R.), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted Big5 -->

      <!-- zh-SG, Chinese (Singapore), is not listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted GB18030 -->

      <tr>
       <td>zh-TW
       <td>Chinese (Taiwan)
       <td>Big5 <!-- Windows Vista, Chrome, and Firefox agreed -->

      <!-- zu-ZA, isiZulu (South Africa), uses windows-1252: Windows Vista and Firefox agreed -->

      <tr>
       <td colspan=2>All other locales
       <td>windows-1252

[24] >>198 の変更分

      <!-- ba wasn't listed at all because none of the sources knew about it. However, further feedback has changed this: -->
      <tr>
       <td>ba
       <td>Bashkir
       <td>windows-1251 <!-- per https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -->
      <!-- be, Belarusian, was not initially listed here because Windows Vista wanted windows-1251, Chrome wanted <none>, and Firefox wanted ISO-8859-5 -->
      <!-- further feedback has changed this: -->
      <tr>
       <td>be
       <td>Belarusian
       <td>windows-1251 <!-- per https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -->
      <!-- kk, Kazakh, was not initially listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->
      <!-- further feedback has changed this: -->
      <tr>
       <td>kk
       <td>Kazakh
       <td>windows-1251 <!-- per https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -->
      <!-- ky, Kyrgyz, was not initially listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->
      <!-- further feedback has changed this: -->
      <tr>
       <td>ky
       <td>Kyrgyz
       <td>windows-1251 <!-- per https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -->
      <!-- mk, Macedonian, was not initially listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->
      <!-- further feedback has changed this: -->
      <tr>
       <td>mk
       <td>Macedonian
       <td>windows-1251 <!-- per https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -->
      <!-- sah wasn't listed at all because none of the sources knew about it. However, further feedback has changed this: -->
      <tr>
       <td>sah
       <td>Yakut
       <td>windows-1251 <!-- per https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -->
      <!-- tg wasn't listed at all because none of the sources knew about it. However, further feedback has changed this: -->
      <tr>
       <td>tg
       <td>Tajik
       <td>windows-1251 <!-- per https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -->
      <!-- tt, Tatar, was not initially listed here because neither Chrome nor Firefox knew about it. For what it's worth, Windows Vista wanted windows-1251 -->
      <!-- further feedback has changed this: -->
      <tr>
       <td>tt
       <td>Tatar
       <td>windows-1251 <!-- per https://www.w3.org/Bugs/Public/show_bug.cgi?id=23089 -->

[203] >>1201 >>1202

      <!-- el, Greek, was not initially listed here because Windows Vista wanted windows-1253, Chrome wanted ISO-8859-7, and Firefox wanted ISO-8859-7 but looked liked it wanted windows-1252 -->
      <!-- further feedback has changed this: -->
      <tr>
       <td>el
       <td>Greek
       <td>ISO-8859-7 <!-- per https://www.w3.org/Bugs/Public/show_bug.cgi?id=23090 -->

[194] 既定値が存在するにも関わらず一定していないのは、当該市場でいずれかの Webブラウザーがそれほど影響力を持っていなかったのか、 文字化けに遭遇するたびに文字コード指定メニューで手動で切り替えていたのか、 既定値まで判断がもつれ込むことが多くなかったのか、 など考えられ、検討が必要です。 挙げられた国の多くが中欧東欧文字コードの混乱があった地域で、 自動判定が失敗しがちな似たような文字コードであることには注意したいです。


[9] 現在の HTML Standard の規定 >>177:

Locale language	Suggested default encoding
ar	Arabic	windows-1256
az	Azeri	windows-1254
ba	Bashkir	windows-1251
be	Belarusian	windows-1251
bg	Bulgarian	windows-1251
cs	Czech	windows-1250
el	Greek	ISO-8859-7
et	Estonian	windows-1257
fa	Persian	windows-1256
he	Hebrew	windows-1255
hr	Croatian	windows-1250
hu	Hungarian	ISO-8859-2
ja	Japanese	Shift_JIS
kk	Kazakh	windows-1251
ko	Korean	EUC-KR
ku	Kurdish	windows-1254
ky	Kyrgyz	windows-1251
lt	Lithuanian	windows-1257
lv	Latvian	windows-1257
mk	Macedonian	windows-1251
pl	Polish	ISO-8859-2
ru	Russian	windows-1251
sah	Yakut	windows-1251
sk	Slovak	windows-1250
sl	Slovenian	ISO-8859-2
sr	Serbian	windows-1251
tg	Tajik	windows-1251
th	Thai	windows-874
tr	Turkish	windows-1254
tt	Tatar	windows-1251
uk	Ukrainian	windows-1251
vi	Vietnamese	windows-1258
zh-Hans, zh-CN, zh-SG	Chinese, Simplified	GBK
zh-Hant, zh-HK, zh-MO, zh-TW	Chinese, Traditional	Big5
All other locales	windows-1252

[11] 改正の過程と実装との差異は複雑に見えますが、 基本的には実態に合わせるための改良であり、 部分タグの扱いの関係と Windows-1252 を既定値の既定値とする表の構造上の複雑さによるところが多いです。

[12] 現在の HTML Standard で規定が欠落しているものの大部分は Windows Vista にあって ChromeFirefox にないロケールです。

[16] いくつか調整が必要と思われるものもあります。

[15] ジョージア語 (ka) は規定が欠落していますが、 現地の利用状況によれば georgian-ps が妥当と思われます。

[13] 蒙古語 (mn) は規定が欠落していますが、 現地の利用状況によれば MNS 4330 が妥当と思われます。

[14] ルーマニア語 (ro) は規定が欠落していますが、 当時の複雑な文字コード事情に起因するものでしょうか。 ISO-8859-2Windows-1250 が使われたもの、 どちらもルーマニア語の文字との同定に問題を抱えていたことと、 ルーマニア語の文字のビット組合せが両者で異なることが状況を複雑にしています。 ただ、 Windows-1252 よりはそのどちらかを選ぶのが妥当と考えられます。 当時の Chrome に合わせて ISO-8859-2 とするべきでしょうか。 (現在の Chrome の実装は不明。)

[193] 越南語 (vi) で Windows-1258 が選ばれたのは特に理由がなさそうで、 単に WindowsANSIコードページだからというだけと思われます。 Windows-1258Web ではほとんど使われていない文字コードです。 Windows-1258 Web で使われた越南語の文字コードの主要な3つのいずれかが好ましいでしょうが、 いずれか1つとも選びかねるところであり、いっそフォント依存符号化と互換性がある Windows-1252 にした方がましという考え方もあります。 越南語の文字コード

言語情報による文字コード判定の補助

[40] 言語情報文字コードの判定に補助的に使うことがあります。 文字コードの判定


[1290] ある SRT の実装では、 BOM → 言語設定から決めた後補を順に試してエラーにならなければ採用 → 判定器。 >>1289

[41] 最初から判定器を使えばいいようにも思われるが、判定器の精度が不十分なので言語依存の決定が増やされてきた経緯のようで。

[42] 言語用字系から Pythoncodec の名前の並びに次のように写像しています。 >>1289

zho
cp936, gb2312, gbk, gb18030, hz, iso2022_jp_2, cp950, gb18030, big5, big5hkscs, utf-16
jpn
shift-jis, cp932, euc_jp, iso2022_jp, iso2022_jp_1, iso2022_jp_2, iso2022_jp_2004, iso2022_jp_3, iso2022_jp_ext
tha
tis-620, cp874
ara, fas, per
windows-1256, utf-16
heb
windows-1255, iso-8859-8
tur
windows-1254, iso-8859-9, iso-8859-3
grc, gre, ell
windows-1253, cp1253, cp737, iso8859-7, cp875, cp869, iso2022_jp_2, mac_greek
pol, cze, ces, slk, slo, hun, bos, hbs, hrv, rsb, ron, rum
windows-1250, iso-8859-2
slv
windows-1250, iso-8859-2, iso-8859-4
sqi, alb
windows-1250, iso-8859-2, windows-1252, iso-8859-15, iso-8859-1, iso-8859-9
bul, mkd, mac, rus, ukr
windows-1251, iso-8859-5
srp
windows-1250, windows-1251, iso-8859-2, iso-8859-5
srp Latn
windows-1250, iso-8859-2
srp Cyrl
windows-1251, iso-8859-5
その他 (西欧・北欧)
latin-1, iso-8859-15, iso-8859-9, iso-8859-4, iso-8859-1

[44] >>42 を見るに、ある程度 subtitle データの実際の状況を反映している可能性が高い (何かの一覧表から機械的に生成したものではない) ものの、 すべて根拠を持って決められているわけでもなさそうです。

[45] 例えばギリシャ語ISO-2022-JP-2 に含まれるのは、 確かに文字コードとしてのカバー範囲でいえば正しいものの、 そのような subtitle が実在しているとは到底思われず、 何らかの情報源からコピペしたものと思われます。

[54] Windowsコードページを優先するような変更 >>49, >>47 などは実態に合わせた修正と考えられます。

TLDによる文字コード判定の補助

[25] TLD文字コードの判定に補助的に使うことがあります。 文字コードの判定

Chrome の実装

[196] cedURL の情報があればヒントとして使うことがあります。 >>43

[20] .hu の場合、ハンガリー語では Latin1Latin2 の区別が難しいとされ、それを考慮したモードに切り替わります。 >>43

[21] .com はヒントとして重視されません。 >>43

Firefox の実装

[22] FirefoxTLD を判定に重視しています。

[39] 現行実装である chardetng では TLD に基づき動作モードが切り替わります。 >>38, >>202, >>201

[23] かつては HTML Standard の既定値に関する規定にも TLD に基づくものを取り込ませようと試みていたようですが、 うまくいっていません。

[211] chardetng は次の各行の最初に示すような動作モードを持っており、 それぞれその続きに示すような TLD と対応付けられています。 >>202

Arabic ae af bh dz eg iq ir jo kw lb ly ma mr om pk ps qa sa sd sy tn xn--lgbbat1ad8j xn--mgb2ddes xn--mgb9awbf xn--mgba3a4f16a xn--mgbaam7a8h xn--mgbah1a3hjkrd xn--mgbai9azgqp6j xn--mgbayh7gpa xn--mgbc0a9azcg xn--mgbcpq6gpa1a xn--mgberp4a5d4ar xn--mgbpl2fh xn--mgbtx2b xn--ogbpf8fl xn--pgbs0dh xn--q7ce6a xn--wgbh1c xn--wgbl6a xn--ygbi2ammx ye
Baltic lt lv
CentralCyrillic ba
CentralIso hu pl si
CentralWindows cz hr ro sk
Cyrillic bg by kg kz md mk mn rs ru su tj tm ua uz xn--80ao21a xn--90a3ac xn--90ae xn--90ais xn--d1alf xn--j1amh xn--l1acc xn--p1ai
Eu eu xn--e1a4c xn--qxa6a
Generic ac ai bz cb cc cd cx dj fm in la me ms nu st tk to tv vc vu (その他)
Greek cy gr xn--qxam
Hebrew il
IcelandicFaroese fo is
Japanese jp
Korean kp kr xn--3e0b707e
Simplified cn xn--fiqs8S xn--fiqz9S
SimplifiedTraditional sg xn--clchc0ea0b2g2a9gcd xn--yfro4i67o
Thai th xn--o3cw4h
Traditional tw xn--kprw13d xn--kpry57d
TraditionalSimplified hk mo xn--j6w193g xn--mix891f
TurkishAzeri az tr
Vietnamese vn
Western edu gov mil xn--54b7fta0cc xn--fzc2c9e2c xn--xkc2al3hye2a (その他の2文字)
WesternArabic my xn--mgbx4cd0ab
WesternCyrillic am ge xn--node xn--y9a3aq

[212] 比較的新しい時代に作られた TLD である IDN の物も含まれていますが、 既存の Webサーバーに割り当てられている場合に対応するためだと説明されています。 >>199, >>202

[213] 最近の新しい gTLD は Generic になります。

[214] 新しい ccTLD は Generic にならず、なぜか Western に収容されます。 欧米等の ccTLD も既定値 Western として定義から省略されています。

[215] 現行および過去の ccTLD との関係を整理すると次のようになります。

  • [216] 明示的に分類されているもの: ac ae af ai am az ba bg bh by bz cc cd cn cx cy cz dj dz eg eu fm fo ge gr hk hr hu il in iq ir is jo jp kg kp kr kw kz la lb lt lv ly ma md me mk mn mo mr ms my nu om pk pl ps qa ro rs ru sa sd sg si sk st su sy th tj tk tm tn to tr tv tw ua uz vc vn vu ye
  • [217] 明示されず Western に分類されるもの
    • [218] 西欧北米およびそれらのその他の海外領土: ad at be ca ch de es fr gb gg gi ie it je li lu mc nl pm pt sh sm tf uk us va
    • [219] 北欧およびそれらのその他の海外領土: ax bv dk ee fi gl no se sj
    • [220] 南欧: al ht mt
    • [221] オセアニア: as au ck fj gu hm ki mh mp nc nf nr nz pf pg pn pw sb wf ws
    • [222] 中南米: ag an ar aw bb bj bm bo bq br bs cl co cr cu cv cw dm do ec fk gf gp gs gt gy hn jm kn ky lc mx ni pa pe pr py sr tc tt uy ve vg vi
    • [223] アフリカ: ao bf bi bw cf cg ci cm eh er et ga gd gh gm gn gq gw ke km lr ls mg ml mq mu mv mw mz na ne ng re rw sc sl sn so ss sv sx sz td tg tz ug yt za zm zw
    • [224] 東南アジア南アジア: bd bn bt id im io kh lk mm np ph tl tp
    • [225] その他: aq
    • [226] 現在および過去に ccTLD として使われていないものすべて

[227] 現地の公用語宗主国との関係、 フォント依存符号化の分布などを考慮すると、 これらを Western に分類するのはおおむね妥当な選択と思われます。

[228] ccTLD が近年新設された事例をみると Western に分類して問題なさそうですが、 基本的には独立前のと同じ値を引き継ぐのが妥当でしょう。 この実装戦略を模倣するなら、未知のものは Generic に分類するのが妥当と思われます。


[26] FirefoxChrome と違って .hu を特別扱いしていません。 .hu に関して両者の性能差は明確ではありませんが、一般論として、 ISO-8859-2Windows-1250Windows-1252 の区別は困難で、 FirefoxChrome もその他の実装も正答率はやや低めです。 西欧と区別しない Firefox の戦略でも十分とするか、 まだ改善の余地があると見るか、判断は難しいところです。

[27] 最悪文字コード指定メニューで救済できる Webブラウザーならともかく、 それを廃止した ChromeFirefox は、 もっと頑張って正答してもらいたいところではありますが... TLD がそれに寄与するかはまた別の問題でもあり...

[28] .my, .xn--mgbx4cd0ab (マレーシア) は WesternArabic に分類されています。これは Western に加えて Windows-1256ISO-8859-6 を考慮したものと思われますが、このようにした理由は不明です。 環境が近い .sg (シンガポール) は SimplifiedTraditional に、 .bn (ブルネイ) は既定値の Western になっていますが、 この違いの理由も不明です。

[29] マレーシア公用語マレー語英語であることから機械的に決定した可能性があり、 実情の調査に基づいていない可能性があります。 マレーシアに限らず他のの選択にも疑念を持たざるを得ないところです。

[30] マレーシアについていえば、確かにマレー語公用語ですが、 Webサイトの多くはラテン文字表記であり、 アラビア文字系のジャビ文字は希少です。 20世紀21世紀初頭の事例は未発見です。 ISO-8859-6Windows-1256マレー語に必要な文字を欠いており、 それらがマレーシアWebサイトマレー語の表記に使われた実例があるのか、 大変疑わしいです。

[31] ブルネイ公用語マレー語と同系統であるブルネイ語ですが、 ブルネイではジャビ文字表記をマレー語よりよく使うといいます。 それを信じるなら、マレーシアと同程度以上にアラビア文字文字コードが出現する可能性はあるのですが、 なぜか WesternArabic になっていません。

[32] マレーシアシンガポール同様に華僑華人が多いことで知られています。 実際にマレーシアWebサイトBig5GB2312 を使ったものが20世紀から複数存在しており、うちいくつかは .my ドメインにありました。 Big5, GB2312 それらを勘案するなら、 マレーシアSimplifiedTraditional とする方が妥当と考えられます。

[33] .vn (ベトナム) は Vietnamese に分類され、これ自体は妥当な選択に見えます。 しかし chardetng越南Webサイト20世紀から21世紀初頭に使われた事例を発見できない Windows-1258 にのみ対応し、当時使われた主要な3つの文字コードのどれにも対応していません。 Windows-1258, 越南語の文字コード

[34] .am, .xn--y9a3aq (アルメニア) と .ge, .xn--node (ジョージア) は WesternCyrillic に分類されています。これは Western に加えてキリル文字文字コードを重視するもののようです。 アルメニアジョージア旧ソ連キリル文字も使っていましたが、 それぞれアルメニア文字ジョージア文字を使っています。 20世紀から21世紀初頭には ARMSCII-8georian-ps が使われていましたが、 chardetng はそれらに対応していません。 そのことに若干の言及はありつつも、 なぜ現況のような設計となったのか説明はありません。 >>201 当然 chardetng は当時の Webサイトを正しく判定できていません。

[35] .in, .lkchardetng を使わず windows-1252 を採用していると説明されています。 >>201 chardetng では既定値の Western となりますが、 そもそも chardetng を使わないことで、フォント依存符号化に対処しているようです。 しかし、フォント依存符号化印度で広く使われた当時 .in は一般に開放されていなかったので、 フォント依存符号化の利用の事例はさほど多くはないようです。 無駄ではないにせよ、むしろ .in よりもそれ以外の gTLD の方がフォント依存符号化の対策が必要なはずですが、 「もしあるなら問題は未解決だ」 >>201 で片付けられています。

[36] chardetngKOI8-RKOI8-U を区別せずすべて KOI8-U と判定しています。これは意図的な選択のようです。 >>201 しかし両者は非互換であり、せっかく TLD が利用できるのですから、 .ua (ウクライナ) なら KOI8-U、 それ以外のキリル文字圏なら KOI8-R と判断するのが穏当でしょう。 なお gTLD 等では区別が困難なので、 KOI8-U に倒しておくのが安全には違いありません。

コードページとロケールの関係

[69] Wine 等の DOSWindowsプログラムPOSIX 環境で動作させるソフトウェアは、 POSIXロケールOEMコードページANSIコードページとの対応関係の表を必要としています。

[70] ZIPファイルファイル名のようなコードページの推定が必要な場面では、 ロケール言語のような情報とコードページの対応関係の表が有用です。 ファイル名の文字コード, 文字コードの判定

コードページと言語や国の関係

[60] MS-DOSWindowsANSIコードページOEMコードページとして使われてきたコードページについて、 その製品の対応言語とその製品が使われた国符号の対応関係。

[61] ただしについては販売地域を厳密に特定するのは資料不足により困難で、 対応言語も十分な資料がなく実際に製品で実装されているか確認されていない便宜的な表に過ぎないことには注意されたい。

[76] 主要コードページから言語
CP437 en / us ca au nz za
CP720 ar / iq
CP737 el / gr
CP775 et lv lt / ee lv lt
CP850 en fr de it pt es nl se / gb fr de it pt at es nl sv
CP852 bs cs hr hu pl ro sk sl sr-latn / ba cz hr hu pl ro sk si rs
CP855 
CP857 tr / tr
CP858 en fr de es it pt / eu gb fr de es it pt
CP860 pt / pt
CP861 is / is
CP862 he iw / il
CP863 fr / ca
CP864 ar / sa iq dz eg
CP865 da nb nn no / dk no
CP866 ru be uk bg sr-cyrl bg mk / ru ua by bg rs bg mk
CP869 el / gr
CP874 th / th
CP932 ja / jp
CP936 zh-cn zh-sg / cn sg
CP949 ko / kr
CP950 zh-tw zh-hk zh-mo / tw hk mo
CP1250 cs hu pl ro sk sl sr-latn / cz hu pl ro sk si rs
CP1251 ru bg uk sr-cyrl mk by / ru bg ua rs mk by
CP1252 en fr de es it pt nl sv da no fi / eu us gb fr de es it pt nl ca au nz at ar
CP1253 el / gr
CP1254 tr / tr
CP1255 he / il
CP1256 ar / sa iq eg dz jo ma
CP1257 et lv lt / ee lv lt
CP1258 vi / vn

[251] ZIPファイルファイル名の読み込み、変換等の実装は、 コードページの一覧や言語等との対応表を持っていたりしますが、 それらの内容は互いに出入りがあったりします。 その対応表の製作過程はあまり詳しく説明されていません。 つまりどの実装もこの分野の確実な情報をそれほど持っていないということです。

[89] >>88 で提示されたコードページ言語符号の関係性

CP437
CP737
CP775 lt lv 
CP850 en 
CP852 bs cs hr hsb hu pl ro sk sl 
CP855
CP857 ku tr 
CP858
CP860
CP861 is 
CP862 he iw 
CP863
CP864 ar 
CP865 da nb nn no 
CP866 ru be bg mk uk 
CP869 el 
CP874 th 
CP932 ja 
CP936 zh 
CP949 ko 
CP950 zh 

[141] >>140コマンドラインで指定されたコードページプラットフォームコードページUTF-8復号して成功したものを使います。その対応コードページの一覧:

  • 日本語 / Japanese (Shift-JIS / EUC-JP)
  • 中国語 / Chinese (GBK / BIG5)
  • 韓国語 / Korean (EUC-KR)
  • ベトナム語 / Vietnamese (Windows-1258)
  • タイ語 / Thai (Windows-874)
  • 英語 / English (CP437 / CP850)
  • 西ヨーロッパ言語 / Western Europe languages (CP850)
  • ギリシャ語 / Greek (CP737)
  • 中央ヨーロッパ言語 / Central Europe languages (CP852)
  • セルビア・ボスニア語 / Serbian & Bosnian (CP855)
  • トルコ語など / Turkish etc. (CP857)
  • ヘブライ語 / Hebrew (CP862)
  • ロシア語など / Russian etc. (CP866)
  • アラビア語 / Arabic (CP720)

[142] これらがどのように選択されたものかは説明がなく不明。

[257] >>256ZIPファイルファイル名の解釈に使う想定で用意された POSIXロケールコードページの対応表。

[258] 437 720 737 775 850 852 857 862 866 874 932 936 949 950 1258 で基本的にOEMコードページ

[260] >>259WinePOSIXロケールからOEMコードページ / ANSIコードページへの対応表を ZIPファイル用に転用したもの。 >>259 の実装ではロケールに加え、 ファイルOSZIP仕様の版によって OEMコードページANSIコードページかを選ぶ。

[264] >>263>>259 からの派生ですが、対応表や判定条件に少し違いがあります。

[62] 判定条件についてはファイル名の文字コード参照。

[71] az_AZsr_RSuz_UZ用字系の違いで2組ずつありますが、 >>263 には用字系ロケール識別子に入っているのに対し、 >>256>>259 では欠落して同名ロケールが2つあることになってしまっています。

[72] zh_MO>>256 にはありますが、 >>259 >>263 からは欠落しています。

[73] それ以外は共通しているようなので、 >>256 >>259 >>263 は共通祖先から派生したもののようです。 >>71 >>72 でどれも不完全なので、補正したものを次に示します。

[74] POSIXロケールからOEMコードページ
    "af_ZA", "CP850", "ar_SA", "CP720", "ar_LB", "CP720", "ar_EG", "CP720",
    "ar_DZ", "CP720", "ar_BH", "CP720", "ar_IQ", "CP720", "ar_JO", "CP720",
    "ar_KW", "CP720", "ar_LY", "CP720", "ar_MA", "CP720", "ar_OM", "CP720",
    "ar_QA", "CP720", "ar_SY", "CP720", "ar_TN", "CP720", "ar_AE", "CP720",
    "ar_YE", "CP720", "ast_ES", "CP850",
    "az_AZ@cyrillic", "CP866", "az_AZ", "CP857",
    "be_BY", "CP866", "bg_BG", "CP866", "br_FR", "CP850", "ca_ES", "CP850",
    "zh_CN", "CP936", "zh_TW", "CP950", "kw_GB", "CP850", "cs_CZ", "CP852",
    "cy_GB", "CP850", "da_DK", "CP850", "de_AT", "CP850", "de_LI", "CP850",
    "de_LU", "CP850", "de_CH", "CP850", "de_DE", "CP850", "el_GR", "CP737",
    "en_AU", "CP850", "en_CA", "CP850", "en_GB", "CP850", "en_IE", "CP850",
    "en_JM", "CP850", "en_BZ", "CP850", "en_PH", "CP437", "en_ZA", "CP437",
    "en_TT", "CP850", "en_US", "CP437", "en_ZW", "CP437", "en_NZ", "CP850",
    "es_PA", "CP850", "es_BO", "CP850", "es_CR", "CP850", "es_DO", "CP850",
    "es_SV", "CP850", "es_EC", "CP850", "es_GT", "CP850", "es_HN", "CP850",
    "es_NI", "CP850", "es_CL", "CP850", "es_MX", "CP850", "es_ES", "CP850",
    "es_CO", "CP850", "es_ES", "CP850", "es_PE", "CP850", "es_AR", "CP850",
    "es_PR", "CP850", "es_VE", "CP850", "es_UY", "CP850", "es_PY", "CP850",
    "et_EE", "CP775", "eu_ES", "CP850", "fa_IR", "CP720", "fi_FI", "CP850",
    "fo_FO", "CP850", "fr_FR", "CP850", "fr_BE", "CP850", "fr_CA", "CP850",
    "fr_LU", "CP850", "fr_MC", "CP850", "fr_CH", "CP850", "ga_IE", "CP437",
    "gd_GB", "CP850", "gv_IM", "CP850", "gl_ES", "CP850", "he_IL", "CP862",
    "hr_HR", "CP852", "hu_HU", "CP852", "id_ID", "CP850", "is_IS", "CP850",
    "it_IT", "CP850", "it_CH", "CP850", "iv_IV", "CP437", "ja_JP", "CP932",
    "kk_KZ", "CP866", "ko_KR", "CP949", "ky_KG", "CP866", "lt_LT", "CP775",
    "lv_LV", "CP775", "mk_MK", "CP866", "mn_MN", "CP866", "ms_BN", "CP850",
    "ms_MY", "CP850", "nl_BE", "CP850", "nl_NL", "CP850", "nl_SR", "CP850",
    "nn_NO", "CP850", "nb_NO", "CP850", "pl_PL", "CP852", "pt_BR", "CP850",
    "pt_PT", "CP850", "rm_CH", "CP850", "ro_RO", "CP852", "ru_RU", "CP866",
    "sk_SK", "CP852", "sl_SI", "CP852", "sq_AL", "CP852", 
    "sr_RS@latin", "CP852", "sr_RS", "CP855",
    "sv_SE", "CP850", "sv_FI", "CP850", "sw_KE", "CP437",
    "th_TH", "CP874", "tr_TR", "CP857", "tt_RU", "CP866", "uk_UA", "CP866",
    "ur_PK", "CP720",
    "uz_UZ@cyrillic", "CP866", "uz_UZ", "CP857",
    "vi_VN", "CP1258", "wa_BE", "CP850",
    "zh_HK", "CP950", "zh_SG", "CP936", "zh_MO", "CP950",
[75] POSIXロケールからANSIコードページ
    "af_ZA", "CP1252", "ar_SA", "CP1256", "ar_LB", "CP1256", "ar_EG", "CP1256",
    "ar_DZ", "CP1256", "ar_BH", "CP1256", "ar_IQ", "CP1256", "ar_JO", "CP1256",
    "ar_KW", "CP1256", "ar_LY", "CP1256", "ar_MA", "CP1256", "ar_OM", "CP1256",
    "ar_QA", "CP1256", "ar_SY", "CP1256", "ar_TN", "CP1256", "ar_AE", "CP1256",
    "ar_YE", "CP1256","ast_ES", "CP1252", 
    "az_AZ@cyrillic", "CP1251", "az_AZ", "CP1254",
    "be_BY", "CP1251", "bg_BG", "CP1251", "br_FR", "CP1252", "ca_ES", "CP1252",
    "zh_CN", "CP936",  "zh_TW", "CP950",  "kw_GB", "CP1252", "cs_CZ", "CP1250",
    "cy_GB", "CP1252", "da_DK", "CP1252", "de_AT", "CP1252", "de_LI", "CP1252",
    "de_LU", "CP1252", "de_CH", "CP1252", "de_DE", "CP1252", "el_GR", "CP1253",
    "en_AU", "CP1252", "en_CA", "CP1252", "en_GB", "CP1252", "en_IE", "CP1252",
    "en_JM", "CP1252", "en_BZ", "CP1252", "en_PH", "CP1252", "en_ZA", "CP1252",
    "en_TT", "CP1252", "en_US", "CP1252", "en_ZW", "CP1252", "en_NZ", "CP1252",
    "es_PA", "CP1252", "es_BO", "CP1252", "es_CR", "CP1252", "es_DO", "CP1252",
    "es_SV", "CP1252", "es_EC", "CP1252", "es_GT", "CP1252", "es_HN", "CP1252",
    "es_NI", "CP1252", "es_CL", "CP1252", "es_MX", "CP1252", "es_ES", "CP1252",
    "es_CO", "CP1252", "es_ES", "CP1252", "es_PE", "CP1252", "es_AR", "CP1252",
    "es_PR", "CP1252", "es_VE", "CP1252", "es_UY", "CP1252", "es_PY", "CP1252",
    "et_EE", "CP1257", "eu_ES", "CP1252", "fa_IR", "CP1256", "fi_FI", "CP1252",
    "fo_FO", "CP1252", "fr_FR", "CP1252", "fr_BE", "CP1252", "fr_CA", "CP1252",
    "fr_LU", "CP1252", "fr_MC", "CP1252", "fr_CH", "CP1252", "ga_IE", "CP1252",
    "gd_GB", "CP1252", "gv_IM", "CP1252", "gl_ES", "CP1252", "he_IL", "CP1255",
    "hr_HR", "CP1250", "hu_HU", "CP1250", "id_ID", "CP1252", "is_IS", "CP1252",
    "it_IT", "CP1252", "it_CH", "CP1252", "iv_IV", "CP1252", "ja_JP", "CP932",
    "kk_KZ", "CP1251", "ko_KR", "CP949", "ky_KG", "CP1251", "lt_LT", "CP1257",
    "lv_LV", "CP1257", "mk_MK", "CP1251", "mn_MN", "CP1251", "ms_BN", "CP1252",
    "ms_MY", "CP1252", "nl_BE", "CP1252", "nl_NL", "CP1252", "nl_SR", "CP1252",
    "nn_NO", "CP1252", "nb_NO", "CP1252", "pl_PL", "CP1250", "pt_BR", "CP1252",
    "pt_PT", "CP1252", "rm_CH", "CP1252", "ro_RO", "CP1250", "ru_RU", "CP1251",
    "sk_SK", "CP1250", "sl_SI", "CP1250", "sq_AL", "CP1250",
    "sr_RS", "CP1251", "sr_RS@latin", "CP1250",
    "sv_SE", "CP1252", "sv_FI", "CP1252", "sw_KE", "CP1252",
    "th_TH", "CP874", "tr_TR", "CP1254", "tt_RU", "CP1251", "uk_UA", "CP1251",
    "ur_PK", "CP1256",
    "uz_UZ@cyrillic", "CP1251", "uz_UZ", "CP1254",
    "vi_VN", "CP1258", "wa_BE", "CP1252",
    "zh_HK", "CP950", "zh_SG", "CP936", "zh_MO", "CP950",

[77] 逆にコードページからロケールへの変換表にすると次の通り。

[78] OEMコードページからPOSIXロケール
CP437 en_PH en_ZA en_US en_ZW ga_IE iv_IV sw_KE
CP720 ar_SA ar_LB ar_EG ar_DZ ar_BH ar_IQ ar_JO ar_KW ar_LY ar_MA ar_OM ar_QA ar_SY ar_TN ar_AE ar_YE fa_IR ur_PK
CP737 el_GR
CP775 et_EE lt_LT lv_LV
CP850 af_ZA ast_ES kw_GB cy_GB da_DK de_AT de_LI de_LU de_CH de_DE en_AU en_CA en_GB en_IE en_JM en_BZ br_FR ca_ES en_TT en_NZ es_PA es_BO es_CR es_DO es_SV es_EC es_GT es_HN es_NI es_CL es_MX es_ES es_CO es_ES es_PE es_AR es_PR es_VE es_UY es_PY eu_ES fi_FI fo_FO fr_FR fr_BE fr_CA fr_LU fr_MC fr_CH gd_GB gv_IM gl_ES id_ID is_IS it_IT it_CH ms_BN ms_MY nl_BE nl_NL nl_SR nn_NO nb_NO pt_BR pt_PT rm_CH sv_SE sv_FI wa_BE
CP852 cs_CZ hr_HR hu_HU pl_PL ro_RO sk_SK sl_SI sq_AL sr_RS@latin
CP855 sr_RS
CP857 az_AZ tr_TR uz_UZ
CP862 he_IL
CP866 az_AZ@cyrillic be_BY bg_BG kk_KZ ky_KG mk_MK mn_MN ru_RU tt_RU uk_UA uz_UZ@cyrillic
CP874 th_TH
CP932 ja_JP
CP936 zh_CN zh_SG
CP949 ko_KR
CP950 zh_TW zh_HK zh_MO
CP1258 vi_VN
[79] ANSIコードページからPOSIXロケール
CP874 th_TH
CP932 ja_JP
CP936 zh_CN zh_SG
CP949 ko_KR
CP950 zh_TW zh_HK zh_MO
CP1250 cs_CZ hr_HR hu_HU pl_PL ro_RO sk_SK sl_SI sq_AL sr_RS@latin
CP1251 az_AZ@cyrillic be_BY bg_BG kk_KZ ky_KG mk_MK mn_MN ru_RU sr_RS tt_RU uk_UA uz_UZ@cyrillic
CP1252 af_ZA ast_ES  br_FR ca_ES kw_GB cy_GB da_DK de_AT de_LI de_LU de_CH de_DE  en_AU en_CA en_GB en_IE en_JM en_BZ en_PH en_ZA en_TT en_US en_ZW en_NZ es_PA es_BO es_CR es_DO es_SV es_EC es_GT es_HN es_NI es_CL es_MX es_ES es_CO es_ES es_PE es_AR es_PR es_VE es_UY es_PY eu_ES fi_FI fo_FO fr_FR fr_BE fr_CA fr_LU fr_MC fr_CH ga_IE gd_GB gv_IM gl_ES id_ID is_IS it_IT it_CH iv_IV ms_BN ms_MY nl_BE nl_NL nl_SR nn_NO nb_NO pt_BR pt_PT rm_CH sv_SE sv_FI sw_KE  wa_BE
CP1253 el_GR
CP1254 az_AZ tr_TR uz_UZ
CP1255 he_IL
CP1256 ar_SA ar_LB ar_EG ar_DZ ar_BH ar_IQ ar_JO ar_KW ar_LY ar_MA ar_OM ar_QA ar_SY ar_TN ar_AE ar_YE fa_IR ur_PK
CP1257 et_EE lv_LV lt_LT
CP1258 vi_VN

[80] 「その他」が CP850 に分類されているような気もしますがどうなのでしょう。 CP437CP850 の区別は実際の製品の販売地域を反映しているのでしょうか。

コードページと ccTLD の関係

[81] 実際のZIPファイルの事例を集めるのは難しいので全体のごく一部分にとどまるでしょうが、 ZIPファイルコードページとそれが所在する ccTLD ( ファイル名の文字コード ) の関係を見てみると次のようになります。

[82] ZIPファイルファイル名コードページccTLD
CP437 .ca 
CP737 .gr 
CP775 .lv 
CP850 .pt 
CP852 .cz .hr .pl
CP866 .bg .mk .ua 
CP874 .th
CP932 .jp
CP936 .cn
CP949 .kr
CP950 .hk .mo .tw
CP1251 
CP1252 .fr
CP1253 .gr 
CP1254 .tr

メモ

[92] ZIPファイルファイル名での利用を想定した分類

メモ