Lingua::JA::Halfwidth - judge given single character is japanese halfwidth or not
use strict; use warnings; use Lingua::JA::Halfwidth; use Encode qw(encode_utf8); use utf8; my $string = qw/aあエ9波ヲ/; for (split //, $string) { print encode_utf8($_), ": "; print is_japanese_halfwidth($_), "\n"; } # a: 0 # あ: 0 # エ: 1 # 9: 0 # 波: 0 # ヲ: 1
This module is aimed to check easily whether given single character is japanese halfwidth or not.
Target character are japanese halfwidth katakana, punctuation, voice marks and bracket. (See also t/01.is_japanese_halfwidth.t)
Unicode block is very useful. When judging japanese halfwidth katakana and character used japanese halfwidth, we use \p{InHalfwidthAndFullwidthForms}. But, this unicode block contains fullwidth number and so on...
So, I made this module :-)
is_japanese_halfwidth($str);
This method can judge given single character is japanese halfwidth or not. Return value is 1 (japanese halfwidth) or 0 (not japanese halfwidth).
sasata299 <sasata299@livedoor.com>
<sasata299@livedoor.com>
http://blog.livedoor.jp/sasata299/
Copyright (c) 2009, sasata299 <sasata299@livedoor.com>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Lingua::JA::Halfwidth, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lingua::JA::Halfwidth
CPAN shell
perl -MCPAN -e shell install Lingua::JA::Halfwidth
For more information on module installation, please visit the detailed CPAN module installation guide.