#!/usr/bin/perl
#
# create code table (Big5) [\0xa1-0xf9][\0x40-\0x7e\0xa1-\0xfe]
#
# 繁體中文 (Big5) 文字內碼表的產生
open (OUT, "> big5tbl.txt"); select OUT;
# 文字內碼表的產生
for ($c1 = 0xA1; $c1 <= 0xF9; $c1++) { # $c1 是第一個位元 [\0xa1-\0xf9]
# 開頭的表示
print "\ncode ";
print "+0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F\n";
$head = "";
$line = "";
$c = 1; # 1行文字數(16文字)
for ($c2 = 0x40; $c2 <= 0xFF; $c2++) { # $c2 是第二個位元
# 開頭第一個字
if ("$head" eq "") {
$head = sprintf ("%02X%02X ", $c1, $c2);
}
# 文字的表示
$line .= " "; # 文字間的空白
if (($c2 == 0x7F) || ($c2 == 0xA0) || ($c2 == 0xFF)) {
$line .= ' ';
} else {
$line .= pack("CC", $c1, $c2);
}
if ($c == 16) { # 16文字表示一行
print "$head$line\n";
$head = "";
$line = "";
$c = 1;
if ($c2 == 0x7F) { $c2 = 0x9F; } # 跳過 [\0x80-0x9f]
} else {
$c++;
}
}
}
close(OUT);
exit;