| line | stmt | bran | cond | sub | pod | time | code | 
| 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 |  |  |  |  |  |  | our $VERSION = do { q$Revision: 1.4 $ =~ /\d+\.(\d+)/; sprintf "%.2f", $1 / 100  }; | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 23217 | use 5.008008; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 45 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 1 |  |  | 1 |  | 5 | use strict; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 31 |  | 
| 12 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 31 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 1 |  |  | 1 |  | 818 | use Encode::Encoding; | 
|  | 1 |  |  |  |  | 12378 |  | 
|  | 1 |  |  |  |  | 40 |  | 
| 15 | 1 |  |  | 1 |  | 8 | use base qw(Encode::Encoding); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 154 |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | __PACKAGE__->Define(qw/skr-1984 skr1984 skr/); | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | sub import { | 
| 20 | 1 |  |  | 1 |  | 18 | require Encode; | 
| 21 | 1 |  |  |  |  | 45 | Encode->export_to_level(1,@_); | 
| 22 |  |  |  |  |  |  | } | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | # == RULES == | 
| 26 | 1 |  |  | 1 |  | 784 | use Encode::Korean::TransliteratorGenerator; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 492 |  | 
| 27 |  |  |  |  |  |  | my $skr = Encode::Korean::TransliteratorGenerator->new(); | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | $skr->consonants(qw(k kk n t tt r m p pp s ss ng ch tch ch' k' t' p' h)); | 
| 30 |  |  |  |  |  |  | $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 |  |  |  |  |  |  | $skr->el('l'); | 
| 54 |  |  |  |  |  |  | $skr->ell('ll'); | 
| 55 |  |  |  |  |  |  | $skr->naught('-'); | 
| 56 |  |  |  |  |  |  | $skr->sep('-'); | 
| 57 |  |  |  |  |  |  | $skr->make(); | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | # == MODES == | 
| 61 |  |  |  |  |  |  | $skr->enmode('greedy'); | 
| 62 |  |  |  |  |  |  | $skr->demode('greedy'); | 
| 63 |  |  |  |  |  |  | my $encode_enc = 'utf8'; | 
| 64 |  |  |  |  |  |  | my $decode_enc = 'utf8'; | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | sub enmode { | 
| 67 | 0 |  |  | 0 | 0 |  | my $class = shift; | 
| 68 | 0 |  |  |  |  |  | my $mode = shift; | 
| 69 | 0 |  |  |  |  |  | my $enc = shift; | 
| 70 | 0 | 0 |  |  |  |  | unless(defined Encode::find_encoding($enc)) { | 
| 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 |  |  |  |  |  |  | sub demode { | 
| 80 | 0 |  |  | 0 | 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 |  |  |  |  |  |  | sub encode ($$;$) { | 
| 93 | 0 |  |  | 0 | 1 |  | my ($obj, $str, $chk) = @_; | 
| 94 | 0 |  |  |  |  |  | my $tr = Encode::encode $encode_enc, $skr->encode($str, $chk); | 
| 95 | 0 | 0 |  |  |  |  | $_[1] = '' if $chk; | 
| 96 | 0 |  |  |  |  |  | return $tr; | 
| 97 |  |  |  |  |  |  | } | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | # | 
| 100 |  |  |  |  |  |  | # === decode === | 
| 101 |  |  |  |  |  |  | # * decode($octets [,$check]) | 
| 102 |  |  |  |  |  |  | # * Decodes transliteration into unicode hangul syllables (Perl internal string) | 
| 103 |  |  |  |  |  |  | sub decode ($$;$) { | 
| 104 | 0 |  |  | 0 | 1 |  | my ($obj, $str, $chk) = @_; | 
| 105 | 0 |  |  |  |  |  | my $han = $skr->decode(Encode::decode($decode_enc, $str), $chk); | 
| 106 | 0 | 0 |  |  |  |  | $_[1] = '' if $chk; | 
| 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; | 
| 116 |  |  |  |  |  |  | __END__ |