NAME
ShiftJIS::CP932::MapUTF - Conversion between Microsoft Windows CP-932 and Unicode
SYNOPSIS
use ShiftJIS::CP932::MapUTF;
$unicode_string = cp932_to_unicode($cp932_string);
DESCRIPTION
The Microsoft Windows CodePage 932 (CP-932) table comprises 7915 characters:
JIS X 0201-1976 single-byte characters (191 characters),
JIS X 0208-1990 double-byte characters (6879 characters),
NEC special characters (83 characters from SJIS row 13),
NEC-selected IBM extended characters (374 characters from SJIS row 89 to 92),
and IBM extended characters (388 characters from SJIS row 115 to 119).
It contains duplicates that do not round trip map. These duplicates are due to the characters defined by vendors, NEC and IBM.
For example, there are two characters that are mapped to U+2252, namely, 0x81e0 (JIS X 0208) and 0x8790 (NEC special character).
This module provides some functions to maps from Windows CP-932 to Unicode, and vice versa.
cp932_to_unicode(STRING)
cp932_to_unicode(CODEREF, STRING)
-
Converts Windows CP-932 to Unicode (UTF-8/UTF-EBCDIC as a Unicode-oriented perl knows).
For example, converts
\x81\xe0
or\x87\x90
toU+2252
in the Unicode.Characters unmapped to Unicode are deleted, if
CODEREF
is not specified; otherwise, converted using theCODEREF
from the Windows CP-932 character string.For example, converts
\x82\xf2
toU+3094
,HIRAGANA LETTER VU
, in the Unicode.cp932_to_unicode( sub { $_[0] eq "\x82\xf2" ? "\x{3094}" : "" }, $cp932_string );
cp932_to_utf16be(STRING)
cp932_to_utf16be(CODEREF, STRING)
-
Converts Windows CP-932 to UTF-16BE.
cp932_to_utf16le(STRING)
cp932_to_utf16le(CODEREF, STRING)
-
Converts Windows CP-932 to UTF-16LE.
For example, converts
\x81\xe0
or\x87\x90
toU+2252
in the UTF-16LE encoding.Characters unmapped to Unicode are deleted, if
CODEREF
is not specified; otherwise, converted using theCODEREF
from the Windows CP-932 character string.For example, converts
\x82\xf2
toU+3094
,HIRAGANA LETTER VU
, in the UTF-16LE encoding.cp932_to_utf16le( sub { $_[0] eq "\x82\xf2" ? "\x94\x30" : "" }, $cp932_string );
unicode_to_cp932(STRING)
unicode_to_cp932(CODEREF, STRING)
-
Converts Unicode (UTF-8/UTF-EBCDIC as a Unicode-oriented perl knows) to Windows CP-932 (normalized).
For example,
U+2252
in the Unicode is converted to\x81\xe0
, not to\x87\x90
.Characters unmapped to Windows CP-932 are deleted, if
CODEREF
is not specified; otherwise, converted using theCODEREF
from its Unicode codepoint (integer).For example, characters unmapped to Windows CP-932 are converted to numerical character references for HTML 4.01.
unicode_to_cp932(sub {sprintf "&#x%04x;", shift}, $unicode_string);
utf16be_to_cp932(STRING)
utf16be_to_cp932(CODEREF, STRING)
-
Converts UTF-16BE to Windows CP-932 (normalized).
utf16le_to_cp932(STRING)
utf16le_to_cp932(CODEREF, STRING)
-
Converts UTF-16LE to Windows CP-932 (normalized).
For example,
U+2252
in the UTF-16LE encoding is converted to\x81\xe0
, not to\x87\x90
.Characters unmapped to Windows CP-932 are deleted, if
CODEREF
is not specified; otherwise, converted using theCODEREF
from its Unicode codepoint (integer).For example, characters unmapped to Windows CP-932 are converted to numerical character references for HTML 4.01.
utf16le_to_cp932(sub {sprintf "&#x%04x;", shift}, $utf16LE_string);
CAVEAT
This module up to version 0.07 treats with "encoded UTF-8", by cp932_to_utf8()
and utf8_to_cp932()
, but these functions are obsolete.
AUTHOR
Tomoyuki SADAHIRO
bqw10602@nifty.com
http://homepage1.nifty.com/nomenclator/perl/
Copyright(C) 2001-2002, SADAHIRO Tomoyuki. Japan. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
- Microsoft PRB: Conversion Problem Between Shift-JIS and Unicode (Article ID: Q170559)
- ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP932.TXT
- perlunicode
- utf8
- ShiftJIS::CP932::Correct