- 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'],
- 'iso-8859-4' => ['iso-8859-2' => '160'],
- 'iso-8859-5' => ['iso-8859-1' => '160'],
- 'iso-8859-6' => ['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'],
- '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'],
-
- 'cp1252' => ['iso-8859-1' => '128-159'],
- 'cp1250' => ['iso-8859-2' => '128-191'],
- 'cp1254' => ['iso-8859-9' => '128-159'],
- 'cp1257' => ['iso-8859-13' => '128-'],
-
- 'cp850' => ['cp437' => '144'],
- 'cp865' => ['cp437' => '144-176'],
- 'cp852' => ['cp850' => '128', 'cp437' => '128'],
- 'cp857' => ['cp850' => '128-239', 'cp437' => '128'],
- 'cp775' => ['cp850' => '128'], # partial cp437
-
- 'MacRomanian' => ['MacRoman' => '160'],
- 'MacCroatian' => ['MacRoman' => '160'],
- 'MacCentralEurRoman' => ['MacRoman' => '128'],
- 'MacTurkish' => ['MacRoman' => '208-223'], # F5 is unassigned
- };
-
- my @parents = @{ $INHERIT->{$input} || [] };
-
- if (my ($parent, $part) = pairfirst { $visible->{$a} } @parents) {