line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Encoding of Korean: Yale Romanization System for Korean Language |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Yale.pm,v 1.6 2007/11/29 14:25:31 you Exp $ |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Encode::Korean::Yale; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = do { q$Revision: 1.6 $ =~ /\d+\.(\d+)/; sprintf "%.2f", $1 / 100 }; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
20416
|
use 5.008008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
37
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
28
|
|
12
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
936
|
use Encode::Encoding; |
|
1
|
|
|
|
|
17572
|
|
|
1
|
|
|
|
|
49
|
|
15
|
1
|
|
|
1
|
|
10
|
use base qw(Encode::Encoding); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
175
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
__PACKAGE__->Define(qw/korean-yale yale/); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub import { |
20
|
1
|
|
|
1
|
|
17
|
require Encode; |
21
|
1
|
|
|
|
|
44
|
Encode->export_to_level(1,@_); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# == RULES == |
26
|
1
|
|
|
1
|
|
756
|
use Encode::Korean::TransliteratorGenerator; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
267
|
|
27
|
|
|
|
|
|
|
my $yale = Encode::Korean::TransliteratorGenerator->new(); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$yale->consonants(qw(k kk n t tt l m p pp s ss ng c cc ch kh th ph h)); |
30
|
|
|
|
|
|
|
$yale->vowels(qw(a ay ya yay e ey ye yey o wa way oy yo wu we wey wi yu u uy i)); |
31
|
|
|
|
|
|
|
#$yale->el('l'); |
32
|
|
|
|
|
|
|
#$yale->ell('ll'); |
33
|
|
|
|
|
|
|
$yale->naught('.'); |
34
|
|
|
|
|
|
|
$yale->sep('.'); |
35
|
|
|
|
|
|
|
$yale->make(); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# == MODES == |
39
|
|
|
|
|
|
|
$yale->enmode('greedy'); |
40
|
|
|
|
|
|
|
$yale->demode('greedy'); |
41
|
|
|
|
|
|
|
sub enmode { |
42
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
43
|
0
|
|
|
|
|
|
my($mode) = @_; |
44
|
0
|
|
|
|
|
|
$yale->enmode($mode); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub demode { |
48
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
49
|
0
|
|
|
|
|
|
my($mode) = @_; |
50
|
0
|
|
|
|
|
|
$yale->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 = $yale->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 = $yale->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__ |