common: align all preformatted html (debug alerts)
[sheet.git] / charset-encoding.inc.pl
index eee5aa252dec757ae6b66ca7e26396c345d16bb7..92330ab0f876092ee425d0412a28d989d1e4ecaa 100644 (file)
@@ -1,5 +1,6 @@
 use 5.014;
 use warnings;
+use utf8;
 
 +{
        default    => [qw( u+0-27F utf8+realsize iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )],
@@ -27,7 +28,7 @@ use warnings;
                           +600 +8A0-8BF+8E0 +750-77F )],
        greek      => [qw( iso-8859-7 cp1253 MacGreek cp737 cp869  +370 +1F00 )],
        hebrew     => [qw( iso-8859-8 cp1255 MacHebrew cp862  +590 )],
-       thai       => [qw( iso-8859-11 cp874 MacThai )],
+       thai       => [qw( iso-8859-11 cp874 MacThai )], # U+0E00 identical to iso-8859-11
        vietnamese => [qw( viscii cp1258 MacVietnamese )],
        symbols    => [qw( symbol dingbats MacDingbats wingdings wingdings2 wingdings3 webdings )],
 
@@ -45,17 +46,75 @@ use warnings;
        11 => 'thai',
 
        'ascii'        => {inherit => ['' => '00-7F']},
-       'cp437'        => {inherit => ['cp850' => 0, 'ascii' => '00-1F+80']}, # ascii range overridden later
+       'cp437'        => {
+               inherit => ['cp850' => 0, 'ascii' => '00-1F+80'], # ascii range overridden later
+               replace => {
+                       0    => ' ☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼', # visible variants of control characters
+                       0xED => 'ϕ', # non-greek usage and appearance
+               },
+       },
        'gsm0338'      => {inherit => ['ascii' => '00-7F']},
        'dingbats'     => {inherit => ['' => '20-7F+A0']},
        'macdingbats'  => {inherit => ['dingbats' => '80-9F']},
        'adobezdingbat'=> {inherit => ['MacDingbats' => '80-9F']}, # should be identical but maps to private use
-       'symbol'       => {inherit => ['' => '20-7F+A0']},
+       'symbol'       => {
+               inherit => ['' => '20-7F+A0'],
+               replace => {
+                       0x60 => '│', # replace radical extender by closest unicode equivalent
+                       0xBD => '⏐⎯', # arrow extenders
+                       0xD2 => '®©™', # serif variants
+                       0xE0 => '◊', # replace lookalike, should match AdobeSymbol
+                       0xE2 => '®©™', # sans-serif variants
+                       0xE6 => '⎛⎜⎝⎡⎢⎣⎧⎨⎩⎪',
+                       0xF0 => '€',
+                       0xF4 => '⎮⌡⎞⎟⎠⎤⎥⎦⎫⎬⎭',
+               },
+       },
        'adobesymbol'  => {inherit => ['symbol' => '20-7F+A0', '' => '20-7F+A0']}, # minor differences, irrelevant except for different '€'
-       'wingdings'    => {inherit => ['' => '20'], setup => sub {require Encode::Wingdings}},
-       'wingdings2'   => {inherit => ['' => '20'], setup => sub {require Encode::Wingdings2}},
-       'wingdings3'   => {inherit => ['' => '20'], setup => sub {require Encode::Wingdings3}},
-       'webdings'     => {inherit => ['' => '20'], setup => sub {require Encode::Webdings}},
+       'wingdings'    => {inherit => ['' => '20'], setup => sub {
+               $_[0]->{table} = [(map {chr} 0 .. 0x20), qw(
+                         🖉 ✂ ✁ 👓 🕭 🕮 🕯 🕿 ✆ 🖂 🖃 📪 📫 📬 📭 📁 📂 📄 🗏 🗐 🗄 ⌛ 🖮 🖰 🖲 🖳 🖴 🖫 🖬 ✇ ✍
+                       🖎 ✌ 👌 👍 👎 ☜ ☞ ☝ ☟ 🖐 ☺ 😐 ☹ 💣 ☠ 🏳 🏱 ✈ ☼ 💧 ❄ 🕆 ✞ 🕈 ✠ ✡ ☪ ☯ ॐ ☸ ♈ ♉
+                       ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓ 🙰 🙵 ● 🔾 ■ □ 🞐 ❑ ❒ ⬧ ⧫ ◆ ❖ ⬥ ⌧ ⮹ ⌘ 🏵 🏶 🙶 🙷 \7f
+                       ⓪ ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⓿ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ 🙢 🙠 🙡 🙣 🙞 🙜 🙝 🙟 · •
+                       ▪ ⚪ 🞆 🞈 ◉ ◎ 🔿 ▪ ◻ 🟂 ✦ ★ ✶ ✴ ✹ ✵ ⯐ ⌖ ⟡ ⌑ ⯑ ✪ ✰ 🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘
+                       🕙 🕚 🕛 ⮰ ⮱ ⮲ ⮳ ⮴ ⮵ ⮶ ⮷ 🙪 🙫 🙕 🙔 🙗 🙖 🙐 🙑 🙒 🙓 ⌫ ⌦ ⮘ ⮚ ⮙ ⮛ ⮈ ⮊ ⮉ ⮋ 🡨
+                       🡪 🡩 🡫 🡬 🡭 🡯 🡮 🡸 🡺 🡹 🡻 🡼 🡽 🡿 🡾 ⇦ ⇨ ⇧ ⇩ ⬄ ⇳ ⬀ ⬁ ⬃ ⬂ 🢬 🢭 🗶 ✔ 🗷 🗹 
+               )];
+       }},
+       'wingdings2'   => {inherit => ['' => '20'], setup => sub {
+               $_[0]->{table} = [(map {chr} 0 .. 0x20), qw(
+                         🖊 🖋 🖌 🖍 ✄ ✀ 🕾 🕽 🗅 🗆 🗇 🗈 🗉 🗊 🗋 🗌 🗍 📋 🗑 🗔 🖵 🖶 🖷 🖸 🖭 🖯 🖱 🖒 🖓 🖘 🖙
+                       🖚 🖛 👈 👉 🖜 🖝 🖞 🖟 🖠 🖡 👆 👇 🖢 🖣 🖑 🗴 ✓ 🗵 ☑ ☒ ☒ ⮾ ⮿ ⦸ ⦸ 🙱 🙴 🙲 🙳 ‽ 🙹 🙺
+                       🙻 🙦 🙤 🙥 🙧 🙚 🙘 🙙 🙛 ⓪ ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⓿ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ \7f
+                       ☉ 🌕 ☽ ☾ ⸿ ✝ 🕇 🕜 🕝 🕞 🕟 🕠 🕡 🕢 🕣 🕤 🕥 🕦 🕧 🙨 🙩 • ● ⚫ ⬤ 🞅 🞆 🞇 🞈 🞊 ⦿ ◾
+                       ■ ◼ ⬛ ⬜ 🞑 🞒 🞓 🞔 ▣ 🞕 🞖 🞗 ⬩ ⬥ ◆ ◇ 🞚 ◈ 🞛 🞜 🞝 ⬪ ⬧ ⧫ ◊ 🞠 ◖ ◗ ⯊ ⯋ ◼ ⬥
+                       ⬟ ⯂ ⬣ ⬢ ⯃ ⯄ 🞡 🞢 🞣 🞤 🞥 🞦 🞧 🞨 🞩 🞪 🞫 🞬 🞭 🞮 🞯 🞰 🞱 🞲 🞳 🞴 🞵 🞶 🞷 🞸 🞹 🞺
+                       🞻 🞼 🞽 🞾 🞿 🟀 🟂 🟄 ✦ 🟉 ★ ✶ 🟋 ✷ 🟏 🟒 ✹ 🟃 🟇 ✯ 🟍 🟔 ⯌ ⯍ ※ ⁂
+               )];
+       }},
+       'wingdings3'   => {inherit => ['' => '20'], setup => sub {
+               $_[0]->{table} = [(map {chr} 0 .. 0x20), qw(
+                         ⭠ ⭢ ⭡ ⭣ ⭦ ⭧ ⭩ ⭨ ⭰ ⭲ ⭱ ⭳ ⭶ ⭸ ⭻ ⭽ ⭤ ⭥ ⭪ ⭬ ⭫ ⭭ ⭍ ⮠ ⮡ ⮢ ⮣ ⮤ ⮥ ⮦ ⮧
+                       ⮐ ⮑ ⮒ ⮓ ⮀ ⮃ ⭾ ⭿ ⮄ ⮆ ⮅ ⮇ ⮏ ⮍ ⮎ ⮌ ⭮ ⭯ ⎋ ⌤ ⌃ ⌥ ⎵ ⏡ ⇪ ⮸ 🢠 🢡 🢢 🢣 🢤 🢥
+                       🢦 🢧 🢨 🢩 🢪 🢫 ← → ↑ ↓ ↖ ↗ ↙ ↘ 🡘 🡙 ▲ ▼ △ ▽ ◄ ► ◁ ▷ ◣ ◢ ◤ ◥ 🞀 🞂 🞁 \7f
+                       🞃 ▲ ▼ ◀ ▶ ⮜ ⮞ ⮝ ⮟ 🠐 🠒 🠑 🠓 🠔 🠖 🠕 🠗 🠘 🠚 🠙 🠛 🠜 🠞 🠝 🠟 🠀 🠂 🠁 🠃 🠄 🠆 🠅
+                       🠇 🠈 🠊 🠉 🠋 🠠 🠢 🠤 🠦 🠨 🠨 🠪 🢜 🢝 🢞 🢟 🠮 🠰 🠲 🠴 🠶 🠸 🠺 🠹 🠻 🢘 🢚 🢙 🢛 🠼 🠾 🠽
+                       🠿 🡀 🡂 🡁 🡃 🡄 🡆 🡅 🡇 ⮨ ⮩ ⮪ ⮫ ⮬ ⮭ ⮮ ⮯ 🡠 🡢 🡡 🡣 🡤 🡥 🡧 🡦 🡰 🡲 🡱 🡳 🡴 🡵 🡷
+                       🡶 🢀 🢂 🢁 🢃 🢄 🢅 🢇 🢆 🢐 🢒 🢑 🢓 🢔 🢖 🢕 🢗
+               )];
+       }},
+       'webdings'     => {inherit => ['' => '20'], setup => sub {
+               $_[0]->{table} = [(map {chr} 0 .. 0x20), qw(
+                         🕷 🕸 🕲 🕶 🏆 🎖 🖇 🗨 🗩 🗰 🗱 🌶 🎗 ▞ 🙼 🗕 🗖 🗗 ⏴ ⏵ ⏶ ⏷ ⏪ ⏩ ⏮ ⏭ ⏸ ⏹ ⏺ 🗚 🗳
+                       🛠 🏗 🏘 🏙 🏚 🏜 🏭 🏛 🏠 🏖 🏝 🛣 🔍 🏔 👁 👂 🏞 🏕 🛤 🏟 🛳 🕬 🕫 🕨 🔈 🎔 🎕 🗬 🙽 🗭 🗪 🗫
+                       ⮔ ✔ 🚲 □ 🛡 📦 🛱 ■ 🚑 🛈 🛩 🛰 🟈 🕴 ⚫ 🛥 🚔 🗘 🗙 ❓ 🛲 🚇 🚍 ⛳ 🛇 ⊖ 🚭 🗮 | 🗯 🗲 \7f
+                       🚹 🚺 🛉 🛊 🚼 👽 🏋 ⛷ 🏂 🏌 🏊 🏄 🏍 🏎 🚘 🗠 🛢 💰 🏷 💳 👪 🗡 🗢 🗣 ✯ 🖄 🖅 🖃 🖆 🖹 🖺 🖻
+                       🕵 🕰 🖽 🖾 📋 🗒 🗓 📖 📚 🗞 🗟 🗃 🗂 🖼 🎭 🎜 🎘 🎙 🎧 💿 🎞 📷 🎟 🎬 📽 📹 📾 📻 🎚 🎛 📺 💻
+                       🖥 🖦 🖧 🕹 🎮 🕻 🕼 📟 🖁 🖀 🖨 🖩 🖿 🖪 🗜 🔒 🔓 🗝 📥 📤 🕳 🌣 🌤 🌥 🌦 ☁ 🌧 🌨 🌩 🌪 🌬 🌫
+                       🌜 🌡 🛋 🛏 🍽 🍸 🛎 🛍 Ⓟ ♿ 🛆 🖈 🎓 🗤 🗥 🗦 🗧 🛪 🐿 🐦 🐟 🐕 🐈 🙬 🙮 🙭 🙯 🗺 🌍 🌏 🌎 🕊
+               )];
+       }},
 
        'iso-8859-2'   => {inherit => ['iso-8859-1' => 'A0']},
        'iso-8859-3'   => {inherit => ['iso-8859-1' => 'A0']}, #TODO: also apply to iso-8859-9
@@ -112,9 +171,33 @@ use warnings;
        'macsami'      => {inherit => ['MacIcelandic' => '90-BF+D0-DF+F0', 'MacRoman' => '90']},
        'macgreek'     => {inherit => ['MacRoman' => '80']},
        'maccyrillic'  => {inherit => ['MacRoman' => '80']},
-       'machebrew'    => {inherit => ['iso-8859-8' => '80', 'MacRoman' => '80-8F+A0']}, # partial ascii
+       'machebrew'    => {
+               inherit => ['iso-8859-8' => '80', 'MacRoman' => '80-8F+A0'], # ignore partial ascii
+               varchar => 1,
+               replace => {
+                       # strip private use characters for unneeded roundtrip
+                       0xDE => chr(0x5C7), # qamats qatan
+                       0xC0 => 'לֹ', # lamed holam
+                       #TODO: private use for canoral codes (obsolete nikud positioning)
+               },
+       },
        'macarabic'    => {inherit => ['iso-8859-6' => '80', 'cp864' => '80', 'MacRoman' => '80']}, #TODO: multiple parents
        'macfarsi'     => {inherit => ['MacArabic' => 'B0-BF', 'MacRoman' => '80']},
+       'macthai'      => {
+               inherit => ['iso-8859-11' => '80-9F+D0'],
+               varchar => 1,
+               replace => {
+                       # strip appended private use characters for unneeded roundtrip
+                       0x83 => "\x{E48}", 0x88 => "\x{E48}", 0x98 => "\x{E48}",
+                       0x84 => "\x{E49}", 0x89 => "\x{E49}", 0x99 => "\x{E49}",
+                       0x85 => "\x{E4A}", 0x8A => "\x{E4A}", 0x9A => "\x{E4A}",
+                       0x86 => "\x{E4B}", 0x8B => "\x{E4B}", 0x9B => "\x{E4B}",
+                       0x87 => "\x{E4C}", 0x8C => "\x{E4C}", 0x9C => "\x{E4C}",
+                       0x8F => "\x{E4D}",
+                       0x92 => "\x{E31}", 0x93 => "\x{E47}", 0x94 => "\x{E34}",
+                       0x95 => "\x{E35}", 0x96 => "\x{E36}", 0x97 => "\x{E37}",
+               },
+       },
 
        'cp37'         => {inherit => ['posix-bc' => '00']},
        'posix-bc'     => {inherit => ['cp1047' => '40']},
@@ -145,8 +228,9 @@ use warnings;
        }},
        u              => {setup => sub {
                my $row = shift;
-               $row->{cell} = do 'charset-unicode.inc.pl'
+               state $celldata = do 'charset-unicode.inc.pl'
                        or Alert('Table data could not be read', $@ || $!);
+               $row->{cell} = $celldata;
 
                $row->{endpoint} ||= 0x1FFF;
                $row->{set} = 'Unicode ' . (
@@ -169,7 +253,6 @@ use warnings;
                $row->{set} = 'UTF-8';
                $row->{cell} = do 'charset-utf8.inc.pl'
                        or Alert('Table data could not be read', $@ || $!);
-               $row->{endpoint} = 0xFF;
                return $row;
        }},
        'utf-8'        => 'utf8',