#_DEFAULT.PROPERTIES OFF
[start]
[CONST]
SJISSPEC=$mircdir $+ sjis-0208-1997-std.txt
#_DEFAULT.PROPERTIES END
ALIAS __SJISspec { return $readini($script,CONST,SJISSPEC) }
ALIAS DEC2HEX {
var %pad = $len($base($$1,10,16))
if (2 \\ %pad) { %pad = %pad + 1 }
if ($isid) { return $base($$1,10,16,%pad) }
elseif ($1 isnum) { echo -aspe 0x $+ $base($$1,10,16,%pad) }
}
ALIAS HEX2DEC {
if ($left($1,2) == 0x) || ($left($1,2) == U+) { tokenize 32 $right($1,-2) }
if ($isid) { return $base($$1,16,10,1) }
else { echo -aspe $base($$1,16,10,1) }
}
alias import_sjis {
if ($hget(sjis)) { /.hfree sjis }
/hmake sjis 10000
/.fopen sjis $qt($__SJISspec)
while (!$fopen(sjis).eof && !$ferr) {
tokenize 09 $fread(sjis)
if ($0 > 2) { var %sjis = $1, %utfc = $2, %desc = $3- }
else { var %sjis = $1, %utfc, %desc = $2- }
if ($+($#,*) iswm %sjis) continue
if ($hex2dec(%sjis) < 128) continue
if (<doublebytes> isin %desc) { /hadd sjis $hex2dec(%sjis) <doublebytes> }
elseif (<cjk> isin %desc) { /hadd sjis $hex2dec(%sjis) $hex2dec(%utfc) $chr($hex2dec(%utfc)) }
elseif ($left(%utfc,2) == U+) { /hadd sjis $hex2dec(%sjis) $hex2dec(%utfc) $chr($hex2dec(%utfc)) }
}
:error
/fclose sjis
}