Skip to content

Instantly share code, notes, and snippets.

@oinume
Created February 7, 2013 02:56
Show Gist options
  • Save oinume/4728039 to your computer and use it in GitHub Desktop.
Save oinume/4728039 to your computer and use it in GitHub Desktop.
./z2h.pl zenkaku_kana.txt > /tmp/hankaku_kana.txt
#!/usr/bin/env perl
use strict;
use warnings;
use Encode;
use Encode::JP::H2Z;
use open ":utf8";
binmode STDOUT, ":utf8";
binmode STDIN, ":utf8";
my $euc = Encode::find_encoding("eucjp");
sub z2h { my $s = $euc->encode(shift); Encode::JP::H2Z::z2h(\$s); $s = $euc->decode($s); }
while (<>) {
print z2h($_);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment