Lingua::KO::MacKorean - transcoding between Mac OS Korean encoding and Unicode
(1) using function names exported by default:
use Lingua::KO::MacKorean; $wchar = decodeMacKorean($octet); $octet = encodeMacKorean($wchar);
(2) using function names exported on request:
use Lingua::KO::MacKorean qw(decode encode); $wchar = decode($octet); $octet = encode($wchar);
(3) using function names fully qualified:
use Lingua::KO::MacKorean (); $wchar = Lingua::KO::MacKorean::decode($octet); $octet = Lingua::KO::MacKorean::encode($wchar); # $wchar : a string in Perl's Unicode format # $octet : a string in Mac OS Korean encoding
This module provides decoding from/encoding to Mac OS Korean encoding (denoted MacKorean hereafter).
In order to ensure roundtrip mapping, MacKorean encoding has some characters with mapping from a single MacKorean character to a sequence of Unicode characters and vice versa. Such characters include 0xAAF9 (MacKorean) from/to 0xF862+0x0028+0x0032+0x0031+0x0029 (Unicode) for "Parenthesized number twenty-one".
0xAAF9
0xF862+0x0028+0x0032+0x0031+0x0029
"Parenthesized number twenty-one"
This module provides functions to transcode between MacKorean and Unicode, without information loss for every MacKorean character.
$wchar = decode($octet)
$wchar = decode($handler, $octet)
$wchar = decodeMacKorean($octet)
$wchar = decodeMacKorean($handler, $octet)
Converts MacKorean to Unicode.
decodeMacKorean() is an alias for decode() exported by default.
decodeMacKorean()
decode()
If the $handler is not specified, any MacKorean character that is not mapped to Unicode is deleted; if the $handler is a code reference, a string returned from that coderef is inserted there. if the $handler is a scalar reference, a string (a PV) in that reference (the referent) is inserted there.
$handler
PV
The 1st argument for the $handler coderef is a string of the unmapped MacKorean character (e.g. "\xC9\xA1").
"\xC9\xA1"
$octet = encode($wchar)
$octet = encode($handler, $wchar)
$octet = encodeMacKorean($wchar)
$octet = encodeMacKorean($handler, $wchar)
Converts Unicode to MacKorean.
encodeMacKorean() is an alias for encode() exported by default.
encodeMacKorean()
encode()
If the $handler is not specified, any Unicode character that is not mapped to MacKorean is deleted; if the $handler is a code reference, a string returned from that coderef is inserted there. if the $handler is a scalar reference, a string (a PV) in that reference (the referent) is inserted there.
The 1st argument for the $handler coderef is the Unicode code point (unsigned integer) of the unmapped character.
E.g.
sub hexNCR { sprintf("&#x%x;", shift) } # hexadecimal NCR sub decNCR { sprintf("&#%d;" , shift) } # decimal NCR print encodeMacKorean("ABC\x{100}\x{10000}"); # "ABC" print encodeMacKorean(\"", "ABC\x{100}\x{10000}"); # "ABC" print encodeMacKorean(\"?", "ABC\x{100}\x{10000}"); # "ABC??" print encodeMacKorean(\&hexNCR, "ABC\x{100}\x{10000}"); # "ABCĀ𐀀" print encodeMacKorean(\&decNCR, "ABC\x{100}\x{10000}"); # "ABCĀ𐀀"
Sorry, the author is not working on a Mac OS. Please let him know if you find something wrong.
SADAHIRO Tomoyuki <SADAHIRO@cpan.org>
Copyright(C) 2003-2007, SADAHIRO Tomoyuki. Japan. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/KOREAN.TXT
http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CORPCHAR.TXT
To install Lingua::KO::MacKorean, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lingua::KO::MacKorean
CPAN shell
perl -MCPAN -e shell install Lingua::KO::MacKorean
For more information on module installation, please visit the detailed CPAN module installation guide.