Codebase list xfonts-mona / debian/2.90-6 ttftools / jis2sjis
debian/2.90-6

Tree @debian/2.90-6 (Download .tar.gz)

jis2sjis @debian/2.90-6raw · history · blame

#!/usr/bin/env perl
# $Id: jis2sjis,v 1.3 2002/09/14 21:07:03 euske Exp $
#
# usage: jis2sjis encodings
#
# convert jis charcode into sjis.
#
#	2002/2, by 1@2ch
#	* public domain *
#

while(<>) {
    chop;
    split(/\s+/);
    my $x = eval($_[0]);
    if (256 <= $x) {
	# not optimized for readers' convenience.
	my $c = (int($x / 256) - 0x21) * (0x7e-0x21+1) + (($x % 256) - 0x21);
	$b1 = int($c / (0xfc-0x40+1-1)) + 0x81;
	$b2 = $c % (0xfc-0x40+1-1) + 0x40;
	$b1 += (0xe0-0xa0) if (0x9f < $b1);
	$b2 += 1 if (0x7e < $b2);
	$x = $b1 * 256 + $b2;
    }

    printf "0x%04x\t%d\n", $x, $_[1];
}