File Coverage

blib/lib/Encode/Korean/ISO_TS_11941.pm
Criterion Covered Total %
statement 20 34 58.8
branch 0 4 0.0
condition n/a
subroutine 7 11 63.6
pod 2 4 50.0
total 29 53 54.7


line stmt bran cond sub pod time code
1             # Encoding of Korean: ISO TS 11941 (formerly, ISO TR 11941)
2              
3             # $Id: ISO_TS_11941.pm,v 1.6 2007/11/29 14:25:31 you Exp $
4              
5             package Encode::Korean::ISO_TS_11941;
6              
7             our $VERSION = do { q$Revision: 1.6 $ =~ /\d+\.(\d+)/; sprintf "%.2f", $1 / 100 };
8              
9 2     2   47268 use 5.008008;
  2         13  
  2         87  
10              
11 2     2   11 use strict;
  2         2  
  2         72  
12 2     2   10 use warnings;
  2         3  
  2         67  
13              
14 2     2   2141 use Encode::Encoding;
  2         27027  
  2         86  
15 2     2   23 use base qw(Encode::Encoding);
  2         4  
  2         319  
16              
17             __PACKAGE__->Define(qw/iso-ts-11941 iso-tr-11941/);
18              
19             sub import {
20 2     2   26 require Encode;
21 2         123 Encode->export_to_level(1,@_);
22             }
23              
24              
25             # == RULES ==
26 2     2   1645 use Encode::Korean::TransliteratorGenerator;
  2         7  
  2         639  
27             my $iso = Encode::Korean::TransliteratorGenerator->new();
28              
29             $iso->consonants(qw(k kk n t tt r m p pp s ss ng c cc ch kh th ph h));
30             $iso->vowels(qw(a ae ya yae eo e yeo ye o wa wae oe yo u weo we wi yu eu yi i));
31             $iso->el('l');
32             $iso->ell('ll');
33             $iso->naught("'");
34             $iso->sep("'");
35             $iso->make();
36              
37              
38             # == MODES ==
39             $iso->enmode('greedy');
40             $iso->demode('greedy');
41             sub enmode {
42 0     0 0   my $class = shift;
43 0           my($mode) = @_;
44 0           $iso->enmode($mode);
45             }
46              
47             sub demode {
48 0     0 0   my $class = shift;
49 0           my($mode) = @_;
50 0           $iso->demode($mode);
51             }
52              
53              
54             # == METHODS ==
55             # === encode ===
56             # * encode($string [,$check])
57             # * Encodes unicode hangul syllables (Perl internal string)
58             # into transliterated (romanized) string
59             sub encode ($$;$) {
60 0     0 1   my ($obj, $str, $chk) = @_;
61 0           my $tr = $iso->encode($str, $chk);
62 0 0         $_[1] = '' if $chk;
63 0           return $tr;
64             }
65              
66             #
67             # === decode ===
68             # * decode($octets [,$check])
69             # * Decodes transliteration into unicode hangul syllables (Perl internal string)
70             sub decode ($$;$) {
71 0     0 1   my ($obj, $str, $chk) = @_;
72 0           my $han = $iso->decode($str, $chk);
73 0 0         $_[1] = '' if $chk;
74 0           return $han;
75             }
76              
77             # === cat_decode ===
78             # * Needs to work with encoding pragma
79             # * cat_decode($destination, $octets, $offset, $terminator [,$check])
80              
81              
82             1;
83             __END__