File: jis2sjis

package info (click to toggle)
xfonts-mona 2.90-8
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 7,896 kB
  • ctags: 333
  • sloc: perl: 11,238; makefile: 442; lisp: 68
file content (27 lines) | stat: -rwxr-xr-x 618 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/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_data = split(/\s+/);
    my $x = eval($split_data[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 "0xx\t%d\n", $x, $_[1];
}