line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Encoding of Korean: SKATS (Standard Korean Alphabet Transliteration System) |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: SKATS.pm,v 1.7 2007/11/29 14:25:31 you Exp $ |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Encode::Korean::SKATS; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = do { q$Revision: 1.7 $ =~ /\d+\.(\d+)/; sprintf "%.2f", $1 / 100 }; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
29028
|
use 5.008008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
12
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
13
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
964
|
use Encode::Encoding; |
|
1
|
|
|
|
|
13836
|
|
|
1
|
|
|
|
|
63
|
|
16
|
1
|
|
|
1
|
|
9
|
use base qw(Encode::Encoding); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
165
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
__PACKAGE__->Define(qw/skats/); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub import { |
21
|
1
|
|
|
1
|
|
19
|
require Encode; |
22
|
1
|
|
|
|
|
107
|
Encode->export_to_level(1,@_); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# == RULES == |
27
|
1
|
|
|
1
|
|
725
|
use Encode::Korean::TransliteratorGenerator; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
507
|
|
28
|
|
|
|
|
|
|
my $skats = Encode::Korean::TransliteratorGenerator->new(); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$skats->consonants(qw(L LL F B BB V M W WW G GG K P PP C X Z O J)); |
31
|
|
|
|
|
|
|
$skats->vowels(qw(E EU I US T TU S SU A AE AEU AU N H HT HTU HU R D DU U)); |
32
|
|
|
|
|
|
|
#$skats->el('l'); |
33
|
|
|
|
|
|
|
#$skats->ell('ll'); |
34
|
|
|
|
|
|
|
$skats->naught(''); |
35
|
|
|
|
|
|
|
$skats->sep(' '); |
36
|
|
|
|
|
|
|
$skats->make(); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$skats->enmode('greedy'); |
39
|
|
|
|
|
|
|
$skats->demode('greedy'); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# == MODES == |
43
|
|
|
|
|
|
|
sub enmode { |
44
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
45
|
0
|
|
|
|
|
|
my($mode) = @_; |
46
|
0
|
|
|
|
|
|
$skats->enmode($mode); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub demode { |
50
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
51
|
0
|
|
|
|
|
|
my($mode) = @_; |
52
|
0
|
|
|
|
|
|
$skats->demode($mode); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# == METHODS == |
57
|
|
|
|
|
|
|
# === encode === |
58
|
|
|
|
|
|
|
# * encode($string [,$check]) |
59
|
|
|
|
|
|
|
# * Encodes unicode hangul syllables (Perl internal string) |
60
|
|
|
|
|
|
|
# into transliterated (romanized) string |
61
|
|
|
|
|
|
|
sub encode ($$;$) { |
62
|
0
|
|
|
0
|
1
|
|
my ($obj, $str, $chk) = @_; |
63
|
0
|
|
|
|
|
|
my $tr; |
64
|
0
|
|
|
|
|
|
my @word = split(/([ ]+)/, $str); |
65
|
0
|
|
|
|
|
|
foreach (@word) { |
66
|
0
|
0
|
|
|
|
|
if ($_ =~ m/([ ]+)/) { |
67
|
0
|
|
|
|
|
|
$tr = $tr . $1 . ' '; |
68
|
|
|
|
|
|
|
} else { |
69
|
0
|
|
|
|
|
|
$tr = $tr . $skats->encode($_, $chk); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
0
|
0
|
|
|
|
|
$_[1] = '' if $chk; |
73
|
0
|
|
|
|
|
|
return $tr; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# |
77
|
|
|
|
|
|
|
# === decode === |
78
|
|
|
|
|
|
|
# * decode($octets [,$check]) |
79
|
|
|
|
|
|
|
# * Decodes transliteration into unicode hangul syllables (Perl internal string) |
80
|
|
|
|
|
|
|
sub decode ($$;$) { |
81
|
0
|
|
|
0
|
1
|
|
my ($obj, $str, $chk) = @_; |
82
|
0
|
|
|
|
|
|
my $han; |
83
|
0
|
|
|
|
|
|
my @word = split(/([ ][ ]+)/, $str); |
84
|
0
|
|
|
|
|
|
foreach (@word) { |
85
|
0
|
0
|
|
|
|
|
if ($_ =~ m/[ ]([ ]+)/) { |
86
|
0
|
|
|
|
|
|
$han = $han . $1; |
87
|
|
|
|
|
|
|
} else { |
88
|
0
|
|
|
|
|
|
$han = $han . $skats->decode($_, $chk); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
0
|
0
|
|
|
|
|
$_[1] = '' if $chk; |
92
|
0
|
|
|
|
|
|
return $han; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# === cat_decode === |
97
|
|
|
|
|
|
|
# * Needs to work with encoding pragma |
98
|
|
|
|
|
|
|
# * cat_decode($destination, $octets, $offset, $terminator [,$check]) |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
__END__ |