Permalink
Browse files

VERSION 0.05

git-svn-id: http://svn.coderepos.org/share/lang/perl/Lingua-JA-Kana/trunk@38936 d0d07461-0603-4401-acd4-de1884942a52
  • Loading branch information...
1 parent 9b06daa commit 4e7d08888bc72102eb27d2d45c2efce017545acb dankogai committed Jun 10, 2011
Showing with 64 additions and 8 deletions.
  1. +11 −2 Changes
  2. +1 −0 MANIFEST
  3. +2 −1 Makefile.PL
  4. +37 −5 lib/Lingua/JA/Kana.pm
  5. +13 −0 t/01-RT.t
View
13 Changes
@@ -1,8 +1,17 @@
# Revision history for Lingua-JA-Kana
#
-# $Id: Changes,v 0.4 2009/02/06 01:16:08 dankogai Exp dankogai $
+# $Id: Changes,v 0.5 2011/06/10 10:23:43 dankogai Exp dankogai $
#
-$Revision: 0.4 $ $Date: 2009/02/06 01:16:08 $
+$Revision: 0.5 $ $Date: 2011/06/10 10:23:43 $
++ t/01-RT.t
+! Makefile.PL
+! lib/Lingua/JA/Kana.pm
+ Added: hankaku2zenkaku and zenkaku2hankaku
+ Addressed:
+ http://rt.cpan.org/Ticket/Display.html?id=39590
+ http://rt.cpan.org/Ticket/Display.html?id=45402
+
+0.04 2009/02/06 01:16:08
! lib/Lingua/JA/Kana.pm
Addressed:
http://rt.cpan.org/Ticket/Display.html?id=39590
View
@@ -5,6 +5,7 @@ Makefile.PL
README
lib/Lingua/JA/Kana.pm
t/00-load.t
+t/01-RT.t
t/boilerplate.t
t/pod-coverage.t
t/pod.t
View
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.PL,v 0.1 2007/12/08 11:09:30 dankogai Exp $
+# $Id: Makefile.PL,v 0.2 2011/06/10 10:23:43 dankogai Exp dankogai $
#
use 5.008001; # needs perl 5.8.1 or better
use strict;
@@ -14,6 +14,7 @@ WriteMakefile(
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
+ 'Encode' => 2.00,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Lingua-JA-Kana-*' },
View
@@ -3,7 +3,7 @@ use warnings;
use strict;
use utf8;
-our $VERSION = sprintf "%d.%02d", q$Revision: 0.4 $ =~ /(\d+)/g;
+our $VERSION = sprintf "%d.%02d", q$Revision: 0.5 $ =~ /(\d+)/g;
require Exporter;
use base qw/Exporter/;
@@ -12,6 +12,7 @@ our @EXPORT = qw(
kata2hira katakana2hiragana
romaji2hiragana romaji2katakana
kana2romaji
+ hankaku2zenkaku zenkaku2hankaku
);
our $USE_REGEXP_ASSEMBLE = do {
@@ -108,6 +109,7 @@ our %Romaji2Kata = qw(
ya ヤ yu ユ ye イェ yo ヨ
xya ャ xyu ュ xyo ョ
ra ラ ri リ ru ル re レ ro ロ
+ rya リャ ryu リュ ryo リョ
la ラ li リ lu ル le レ lo ロ
wa ワ wo ヲ
wi ウィ we ウェ
@@ -135,13 +137,13 @@ our $Re_Kana2Romaji = $Re_Kana2Hepburn;
sub katakana2hiragana{
my $str = shift;
- $str =~ tr/ァ-/ぁ-/;
+ $str =~ tr/ァ-ンヴ/ぁ-んゔ/;
$str;
}
sub hiragana2katakana{
my $str = shift;
- $str =~ tr/ぁ-/ァ-/;
+ $str =~ tr/ぁ-んゔ/ァ-ンヴ/;
$str;
}
@@ -190,8 +192,26 @@ if ($0 eq __FILE__){
print kana2romaji("ダンコガイ");
print kana2romaji("マイッタ");
print kana2romaji("シンバシ");
+ print romaji2hiragana("ryoukai"); # RT#39590
+ print romaji2hiragana("virama"); # RT#45402
}
+use Encode;
+use Encode::JP::H2Z;
+my $eucjp = Encode::find_encoding('eucjp');
+sub hankaku2zenkaku {
+ my $str = $eucjp->encode(shift);
+ Encode::JP::H2Z::h2z(\$str);
+ $eucjp->decode($str);
+}
+
+sub zenkaku2hankaku {
+ my $str = $eucjp->encode(shift);
+ Encode::JP::H2Z::z2h(\$str);
+ $eucjp->decode($str);
+}
+
+
1; # End of Lingua::JA::Kana
__END__
@@ -201,7 +221,7 @@ Lingua::JA::Kana - Kata-Romaji related utilities
=head1 VERSION
-$Id: Kana.pm,v 0.4 2009/02/06 01:16:08 dankogai Exp dankogai $
+$Id: Kana.pm,v 0.5 2011/06/10 10:23:43 dankogai Exp dankogai $
=head1 SYNOPSIS
@@ -277,7 +297,19 @@ Converts all occurance of kana (both katakana and hiragana) to romaji.
my $romaji = kana2romaji($str);
-INSTALLATION
+=head2 hankaku2zenkaku
+
+Converts all occurance of hankaku to zenkaku.
+
+ my $romaji = hankaku2zenkaku($str);
+
+=head2 zenkaku2hankaku
+
+Converts all occurance of zenkaku to hankaku.
+
+ my $romaji = zenkaku2hankaku($str);
+
+=head1 INSTALLATION
To install this module, run the following commands:
View
@@ -0,0 +1,13 @@
+#!perl -T
+#
+# $Id: 01-RT.t,v 0.1 2011/06/10 10:23:11 dankogai Exp $
+#
+use strict;
+use warnings;
+use Test::More;
+use Lingua::JA::Kana;
+
+plan tests => 2;
+use utf8;
+is romaji2hiragana("ryoukai"), 'りょうかい', 'RT#39590';
+is romaji2hiragana("virama"), 'ゔぃらま', 'RT#45402';

0 comments on commit 4e7d088

Please sign in to comment.