Last active
March 31, 2019 10:48
-
-
Save xtetsuji/3a5cd7786ec480e7c42df5350293bcf4 to your computer and use it in GitHub Desktop.
Perl kanji processing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# see: http://www.asahi-net.or.jp/~ax2s-kmtn/ref/unicode/cjku_klist.html | |
use strict; | |
use warnings; | |
use utf8; | |
binmode STDOUT, ':utf8'; | |
# ほぼ Unicode 全漢字を集める | |
my ($start, $end) = (0x4E00, 0x9FAF); | |
my @kanjis; | |
for my $point ($start .. $end) { | |
my $kanji = chr $point; | |
push @kanjis, $kanji; | |
# print "[$point] $kanji\n"; | |
} | |
for (1..10) { | |
my ($kanji1, $kanji2) = map { $kanjis[ int(rand @kanjis) ] } (1,2); | |
print "元号は「${kanji1}${kanji2}」です!\n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# Whole (?) kanji list. | |
# http://www.asahi-net.or.jp/~ax2s-kmtn/ref/unicode/cjku_klist.html | |
use strict; | |
use warnings; | |
use utf8; | |
binmode STDOUT, ':utf8'; | |
my ($start, $end) = (0x4E00, 0x9FAF); | |
for my $point ($start .. $end) { | |
print "[$point] " . chr($point) . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment