ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/vendor/ircservices-5.1.24/lang/jconv.pl
Revision: 3389
Committed: Fri Apr 25 14:12:15 2014 UTC (9 years, 11 months ago) by michael
Content type: text/x-perl
File size: 1049 byte(s)
Log Message:
- Imported ircservices-5.1.24

File Contents

# Content
1 #!/usr/bin/perl
2
3 binmode STDIN;
4 binmode STDOUT;
5 undef $/;
6 $text = <STDIN>;
7 if ($ARGV[0] eq "-jis") {
8 $text =~ s/EUC/JIS/g;
9 $text =~ s/euc-jp/iso-2022-jp/g;
10 $text =~ s#([\241-\376])([\241-\376])#
11 "\033\$B".pack("cc",ord($1)&127,ord($2)&127)."\033(B"#eg;
12 # The language name (the only thing before the STRFTIME_* strings)
13 # shouldn't have its %'s escaped; all other strings should, because
14 # they go through sprintf().
15 $pos = index($text, "STRFTIME");
16 $pos = length($text) if $pos == 0;
17 $t1 = substr($text, 0, $pos);
18 $t2 = substr($text, $pos, length($text)-$pos);
19 $t2 =~ s#(\033\$B.)%(\033\(B)#\1%%\2#g;
20 $t2 =~ s#(\033\$B)%(.\033\(B)#\1%%\2#g;
21 $text = $t1 . $t2;
22 $text =~ s#\033\(B\033\$B##g;
23 } elsif ($ARGV[0] eq "-sjis") {
24 $text =~ s/EUC/SJIS/g;
25 $text =~ s/euc-jp/shift_jis/g;
26 $text =~ s#([\241-\376])([\241-\376])#
27 $x = 0201+(ord($1)-0241)/2;
28 $y = 0100+(ord($2)-0241)+((ord($1)-0241)%2)*94;
29 $x += 0100 if $x >= 0240;
30 $y++ if $y >= 0177;
31 pack("cc",$x,$y)#eg;
32 }
33 print $text;