- use List::Util qw( first pairfirst pairs );
-
- state $INHERIT = {
- 'cp437' => ['cp850' => 0], # ascii range overridden later
- 'gsm0338' => ['ascii' => '0-127'],
-
- 'iso-8859-2' => ['iso-8859-1' => '160'],
- 'iso-8859-3' => ['iso-8859-1' => '160'], #TODO: also apply to iso-8859-9
- 'iso-8859-4' => ['iso-8859-2' => '160'],
- 'iso-8859-5' => ['iso-8859-1' => '160'],
- 'iso-8859-6' => ['cp1256' => '128', 'iso-8859-1' => '160'],
- 'iso-8859-7' => ['iso-8859-1' => '160'],
- 'iso-8859-8' => ['iso-8859-1' => '160'],
- 'iso-8859-9' => ['iso-8859-1' => '208-223+240'],
- 'iso-8859-10' => ['iso-8859-4' => '160'],
- 'iso-8859-11' => ['iso-8859-1' => '160'],
- 'iso-8859-13' => ['iso-8859-4' => '160'],
- 'iso-8859-14' => ['iso-8859-1' => '160'],
- 'iso-8859-15' => ['iso-8859-1' => '160-191'],
- 'iso-8859-16' => ['iso-8859-2' => '160'],
- 'hp-roman8' => ['iso-8859-1' => '160'],
-
- 'cp1252' => ['iso-8859-1' => '128-159'],
- 'cp1250' => ['iso-8859-2' => '128-191', 'cp1252' => '128'],
- 'cp1254' => ['iso-8859-9' => '128-159', 'cp1252' => '128-159+208'],
- 'cp874' => ['iso-8859-11' => '128-159', 'cp1252' => '128'], # windows-874 actually cp1162
- 'cp1257' => ['iso-8859-13' => '128-159+255', 'cp1252' => '128'],
- 'cp1251' => ['cp1252' => '128'],
- 'cp1253' => ['cp1252' => '128'],
- 'cp1255' => ['iso-8859-8' => '128-223', 'cp1252' => '128'],
- 'cp1256' => ['cp1252' => '128'],
- 'cp1258' => ['cp1252' => '128-159+192'],
-
- 'cp850' => ['cp437' => '144'],
- 'cp860' => ['cp437' => '128-175'],
- 'cp861' => ['cp865' => '128-175'],
- 'cp863' => ['cp437' => '128-175'],
- 'cp865' => ['cp437' => '144-175'],
- 'cp852' => ['cp850' => '128', 'cp437' => '128'],
- 'cp857' => ['cp850' => '128-175+208-239', 'cp437' => '128'],
- 'cp775' => ['cp850' => '128'], # partial cp437
- 'cp866' => ['cp437' => '128-175+224'],
- 'cp855' => ['cp437' => '128'],
- 'cp1006' => ['iso-8859-6' => '160', 'cp437' => '128'],
- 'cp737' => ['cp437' => '128-175+224'],
- 'cp869' => ['cp437' => '128'],
- 'cp862' => ['cp437' => '128-159'],
- 'cp864' => ['MacArabic' => '128', 'iso-8859-6' => '128', 'cp437' => '128'], #TODO: compare form variants
-
- 'koi8-u' => ['koi8-r' => 128],
- 'koi8-f' => ['koi8-u' => 128],
-
- 'MacRomanian' => ['MacRoman' => '160-191+208-223'],
- 'MacRumanian' => ['MacRomanian' => '160-191+208-223', 'MacRoman' => '160-191+208-223'],
- 'MacCroatian' => ['MacRoman' => '160'],
- 'MacCentralEurRoman' => ['MacRoman' => '128'],
- 'MacIcelandic'=> ['MacRoman' => '160-175+208-239'], #TODO: gaps at C/E
- 'MacTurkish' => ['MacRoman' => '208-223'], # F5 is unassigned
- 'MacSami' => ['MacIcelandic' => '144', 'MacRoman' => '144'],
- 'MacGreek' => ['MacRoman' => '128'],
- 'MacCyrillic' => ['MacRoman' => '128'],
- 'MacHebrew' => ['iso-8859-8' => '128', 'MacRoman' => '128-143+160'], # partial ascii
- 'MacArabic' => ['iso-8859-6' => '128', 'cp864' => '128', 'MacRoman' => '128'], #TODO: multiple parents
- 'MacFarsi' => ['MacArabic' => '176-191', 'MacRoman' => '128'],
-
- 'cp37' => ['posix-bc' => '0'],
- 'posix-bc' => ['cp1047' => '64'],
- 'cp500' => ['cp37' => '64-95+176-191'],
- 'cp1047' => ['cp37' => '16-95+160-191'], #TODO: gap at 3/4
- 'cp1026' => ['cp37' => '64'],
- 'cp875' => ['cp37' => '48'],
-
- };
-
- my @parents = @{ $INHERIT->{$input} || [] };