Korean/SKR_1984.pm

filter: Statementstmt 64.2% 36 / 56 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 63.6% 7 / 11 Podpod 50.0% 2 / 4 totaltotal 58.4% 45 / 77 CC 4 SCAR 11.7
CC
4
Cov
58%
enmode
6.0
encode
6.0
decode
6.0
CRAP 3.2
« Korean.pm ↑ Summary Korean/Yale.pm »
1 # Encoding of Korean: South Korean Romanization 1984
2  
3 # $Id: SKR_1984.pm,v 1.4 2007/11/29 14:25:31 you Exp $
4  
5 package Encode::Korean::SKR_1984;
6  
7 1 our $VERSION = do { q$Revision: 1.4 $ =~ /\d+\.(\d+)/; sprintf "%.2f", $1 / 100 };
8  
9 1 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Encode::Encoding;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use base qw(Encode::Encoding);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 __PACKAGE__->Define(qw/skr-1984 skr1984 skr/);
18  
19 1 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
20 1 require Encode;
21 1 Encode->export_to_level(1,@_);
22 }
23  
24  
25 # == RULES ==
26 1 ▶use Encode::Korean::TransliteratorGenerator;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 my $skr = Encode::Korean::TransliteratorGenerator->new();
28  
29 1 $skr->consonants(qw(k kk n t tt r m p pp s ss ng ch tch ch' k' t' p' h));
30 1 $skr->vowels(
31 "a",
32 "ae",
33 "ya",
34 "yae",
35 "\x{014F}", # \x{014F} latin small letter o with breve (ŏ)
36 "e",
37 "y\x{014F}",
38 "ye",
39 "o",
40 "wa",
41 "wae",
42 "oe",
43 "yo",
44 "u",
45 "wo",
46 "we",
47 "wi",
48 "yu",
49 "\x{016D}", # \x{016D} latin small letter u with breve (ŭ)
50 "\x{016D}y",
51 "i"
52 );
53 1 $skr->el('l');
54 1 $skr->ell('ll');
55 1 $skr->naught('-');
56 1 $skr->sep('-');
57 1 $skr->make();
58  
59  
60 # == MODES ==
61 1 $skr->enmode('greedy');
62 1 $skr->demode('greedy');
63 1 my $encode_enc = 'utf8';
64 1 my $decode_enc = 'utf8';
65  
66 0 ▶sub enmode {
Subroutine enmode: not called CC=2 SCAR=17.9
Pod undocumented
67 0 my $class = shift;
68 0 my $mode = shift;
69 0 my $enc = shift;
70 0 ▶ unless(defined Encode::find_encoding($enc)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined &Encode::find_encoding($enc)) 0 0 0
71 0 require Carp;
72 0 Carp::croak("Unknown encoding '$enc'");
73 }
74  
75 0 $skr->enmode($mode);
76 0 $encode_enc = $enc;
77 }
78  
79 0 ▶sub demode {
Subroutine demode: not called CC=1 SCAR=6.9
Pod undocumented
80 0 my $class = shift;
81 0 my($mode, $enc) = @_;
82 0 $skr->demode($mode);
83 0 $decode_enc = $enc;
84 }
85  
86  
87 # == METHODS ==
88 # === encode ===
89 # * encode($string [,$check])
90 # * Encodes unicode hangul syllables (Perl internal string)
91 # into transliterated (romanized) string
92 0 ▶sub encode ($$;$) {
Subroutine encode: not called CC=2 SCAR=17.9
Pod documented
93 0 my ($obj, $str, $chk) = @_;
94 0 my $tr = Encode::encode $encode_enc, $skr->encode($str, $chk);
95 0 ▶ $_[1] = '' if $chk;
Branch: 1 branch
BranchTrueFalseTotal
if $chk 0 0 0
96 0 return $tr;
97 }
98  
99 #
100 # === decode ===
101 # * decode($octets [,$check])
102 # * Decodes transliteration into unicode hangul syllables (Perl internal string)
103 0 ▶sub decode ($$;$) {
Subroutine decode: not called CC=2 SCAR=17.9
Pod documented
104 0 my ($obj, $str, $chk) = @_;
105 0 my $han = $skr->decode(Encode::decode($decode_enc, $str), $chk);
106 0 ▶ $_[1] = '' if $chk;
Branch: 1 branch
BranchTrueFalseTotal
if $chk 0 0 0
107 0 return $han;
108 }
109  
110 # === cat_decode ===
111 # * Needs to work with encoding pragma
112 # * cat_decode($destination, $octets, $offset, $terminator [,$check])
113  
114  
115 1 1;
116 __END__
« Korean.pm ↑ Summary Korean/Yale.pm »