NAME

Jacode4e - jacode.pl-like program for enterprise

SYNOPSIS

 use FindBin;
 use lib "$FindBin::Bin/lib";
 use Jacode4e;

 $return =
 Jacode4e::convert(\$line, $OUTPUT_encoding, $INPUT_encoding [, { %option }]);

   $return
     Number of characters in $line

   $line
     String variable to convert
     After conversion, this variable is overwritten

   $OUTPUT_encoding, and $INPUT_encoding
     To convert, you must specify both $OUTPUT_encoding and $INPUT_encoding.
     The encodings you can specify are as follows:

     mnemonic      means
     -----------------------------------------------------------------------
     cp932x        CP932X, Extended CP932 to JIS X 0213 using 0x9C5A as single shift
     cp932         Microsoft CP932, IANA Windows-31J
     sjis2004      JISC Shift_JIS-2004
     cp00930       IBM CP00930(CP00290+CP00300), CCSID 5026 katakana
     keis78        HITACHI KEIS78
     keis83        HITACHI KEIS83
     keis90        HITACHI KEIS90
     jef           FUJITSU JEF (12 point size for printing with option OUTPUT_SHIFTING)
     jef9p         FUJITSU JEF ( 9 point size for printing with option OUTPUT_SHIFTING)
     jipsj         NEC JIPS(J)
     jipse         NEC JIPS(E)
     letsj         UNISYS LetsJ
     utf8          UTF-8
     utf8jp        UTF-8-SPUA-JP, JIS X 0213 on SPUA ordered by JIS level, plane, row, cell
     -----------------------------------------------------------------------

   %option
     The options you can specify are as follows:

     key mnemonic      value means
     -----------------------------------------------------------------------
     INPUT_LAYOUT      input record layout by 'S' and 'D' sequence
                       'S' means one char as SBCS, 'D' means one char as DBCS
                       each letter may optionally be followed by a number
                       indicating the repeat count, see samples
     OUTPUT_SHIFTING   true means use output shift code, false means not use
                       default is false
     SPACE             output space code in DBCS/MBCS
     GETA              output geta code in DBCS/MBCS
     OVERRIDE_MAPPING  hash reference of FROM => TO override mapping
                       { "\x12\x34"=>"\x56\x78", "\x9A\xBC"=>"\xDE\xFE", }
                       (CAUTION! override also SPACE option)
     -----------------------------------------------------------------------

SAMPLES

 use FindBin;
 use lib "$FindBin::Bin/lib";
 use Jacode4e;
 Jacode4e::VERSION('2.13.6.11');
 while (<>) {
     $return =
     Jacode4e::convert(\$_, 'cp932x', 'cp00930', {
         'INPUT_LAYOUT'     => 'SSSDDDSSDDSDSD',
         'OUTPUT_SHIFTING'  => 0,
         'SPACE'            => "\x81\xA2",
         'GETA'             => "\x81\xA1",
         'OVERRIDE_MAPPING' => { "\x44\x5A" => "\x81\x7C", },
     });
     print $_;
 }

 while (<>) {
     $return =
     Jacode4e::convert(\$_, 'cp932x', 'cp00930', {
         'INPUT_LAYOUT'     => 'S3D3S2D2SDSD',
         'OUTPUT_SHIFTING'  => 0,
         'SPACE'            => "\x81\xA2",
         'GETA'             => "\x81\xA1",
         'OVERRIDE_MAPPING' => { "\x44\x5A" => "\x81\x7C", },
     });
     print $_;
 }

INPUT SI/SO code

Wikipedia tells us Kanji shift code of each encoding of vendors.
Jacode4e::convert() handle SI/SO(Shift In and Shift Out) code in $line
automatically. If $line has no SI/SO code, we can use option INPUT_LAYOUT
instead of SI/SO code.

Actually saying, we have to use option INPUT_LAYOUT almost always, if
$INPUT_encoding is any of enterprise encodings.

If $INPUT_encoding is cp932x or cp932 or sjis2004, the INPUT_LAYOUT option
is unnecessary. This is because SBCS and DBCS can be judged from the character
string itself. However, you can also use the INPUT_LAYOUT option to force
conversion as SBCS.

---------------------------------------------------------------------------
                   SO(Shift Out)       SI(Shift In)
$INPUT_encoding    KI(KANJI In)        KO(KANJI Out)
mnemonic           switch to DBCS      switch to SBCS    %option
---------------------------------------------------------------------------
'cp932x'           (nothing)           (nothing)         also 'INPUT_LAYOUT' => ...
'cp932'            (nothing)           (nothing)         also 'INPUT_LAYOUT' => ...
'sjis2004'         (nothing)           (nothing)         also 'INPUT_LAYOUT' => ...
'cp00930'          "\x0E"              "\x0F"            xor 'INPUT_LAYOUT' => ...
'keis78'           "\x0A\x42"          "\x0A\x41"        xor 'INPUT_LAYOUT' => ...
'keis83'           "\x0A\x42"          "\x0A\x41"        xor 'INPUT_LAYOUT' => ...
'keis90'           "\x0A\x42"          "\x0A\x41"        xor 'INPUT_LAYOUT' => ...
'jef'              "\x28" or "\x38"    "\x29"            xor 'INPUT_LAYOUT' => ...
'jef9p'            "\x28" or "\x38"    "\x29"            xor 'INPUT_LAYOUT' => ...
'jipsj'            "\x1A\x70"          "\x1A\x71"        xor 'INPUT_LAYOUT' => ...
'jipse'            "\x3F\x75"          "\x3F\x76"        xor 'INPUT_LAYOUT' => ...
'letsj'            "\x93\x70"          "\x93\xF1"        xor 'INPUT_LAYOUT' => ...
'utf8'             (nothing)           (nothing)         
'utf8jp'           (nothing)           (nothing)         
---------------------------------------------------------------------------

OUTPUT SI/SO code

Jacode4e::convert() doesn't output SI/SO code on default. Thus, if you
need SI/SO code then you have to use option 'OUTPUT_SHIFTING' => 1.

---------------------------------------------------------------------------
                   SO(Shift Out)       SI(Shift In)
$OUTPUT_encoding   KI(KANJI In)        KO(KANJI Out)
mnemonic           switch to DBCS      switch to SBCS    %option
---------------------------------------------------------------------------
'cp932x'           (nothing)           (nothing)         
'cp932'            (nothing)           (nothing)         
'sjis2004'         (nothing)           (nothing)         
'cp00930'          "\x0E"              "\x0F"            'OUTPUT_SHIFTING' => 1
'keis78'           "\x0A\x42"          "\x0A\x41"        'OUTPUT_SHIFTING' => 1
'keis83'           "\x0A\x42"          "\x0A\x41"        'OUTPUT_SHIFTING' => 1
'keis90'           "\x0A\x42"          "\x0A\x41"        'OUTPUT_SHIFTING' => 1
'jef'              "\x28"              "\x29"            'OUTPUT_SHIFTING' => 1
'jef9p'            "\x38"              "\x29"            'OUTPUT_SHIFTING' => 1
'jipsj'            "\x1A\x70"          "\x1A\x71"        'OUTPUT_SHIFTING' => 1
'jipse'            "\x3F\x75"          "\x3F\x76"        'OUTPUT_SHIFTING' => 1
'letsj'            "\x93\x70"          "\x93\xF1"        'OUTPUT_SHIFTING' => 1
'utf8'             (nothing)           (nothing)         
'utf8jp'           (nothing)           (nothing)         
---------------------------------------------------------------------------

OUTPUT DBCS/MBCS SPACE code

The default space code is as follows.
You can change the space code using the option 'SPACE' if you want.

---------------------------------------------------------------------------
$OUTPUT_encoding
mnemonic           default code        %option
---------------------------------------------------------------------------
'cp932x'           "\x81\x40"          
'cp932'            "\x81\x40"          
'sjis2004'         "\x81\x40"          'SPACE' => "\x20\x20" for CP/M-86 compatible
'cp00930'          "\x40\x40"          
'keis78'           "\xA1\xA1"          
'keis83'           "\xA1\xA1"          
'keis90'           "\xA1\xA1"          
'jef'              "\xA1\xA1"          'SPACE' => "\x40\x40" for 99FR-0012-2 and 99FR-0012-3 compatible
'jef9p'            "\xA1\xA1"          'SPACE' => "\x40\x40" for 99FR-0012-2 and 99FR-0012-3 compatible
'jipsj'            "\x21\x21"          
'jipse'            "\x4F\x4F"          
'letsj'            "\x20\x20"          'SPACE' => "\xA1\xA1" for EUC-JP like space
'utf8'             "\xE3\x80\x80"      
'utf8jp'           "\xF3\xB0\x84\x80"  
---------------------------------------------------------------------------

OUTPUT DBCS/MBCS GETA code

If a character isn't included in $OUTPUT_encoding set, GETA code will be
used instead of converted code.

The default GETA code is as follows.
You can change GETA code using option 'GETA' if you want.

"GETA" doesn't mean "GETA", but means "GETA-MARK".

GETA is Japanese wooden shoes that made for walk on paddy field. One GETA
has two teeth, and they make GETA-MARK on the ground by bite the earth
twice. Thus, GETA code is double byte code, or often multibyte code.

---------------------------------------------------------------------------
$OUTPUT_encoding
mnemonic           default code        %option sample
---------------------------------------------------------------------------
'cp932x'           "\x81\xAC"          'GETA' => "\x81\xA1"
'cp932'            "\x81\xAC"          'GETA' => "\x81\x9C"
'sjis2004'         "\x81\xAC"          'GETA' => "\x81\xFC"
'cp00930'          "\x44\x7D"          
'keis78'           "\xA2\xAE"          
'keis83'           "\xA2\xAE"          
'keis90'           "\xA2\xAE"          
'jef'              "\xA2\xAE"          
'jef9p'            "\xA2\xAE"          
'jipsj'            "\x22\x2E"          
'jipse'            "\x7F\x4B"          
'letsj'            "\xA2\xAE"          
'utf8'             "\xE3\x80\x93"      
'utf8jp'           "\xF3\xB0\x85\xAB"  
---------------------------------------------------------------------------

RAISON D'ETRE

This software has been developed for use promotion of JIS X 0213.

JIS X 0213 contains almost all of the characters used in everyday life in
Japan. In addition, JIS X 0213 was designed with consideration for use
in Shift_JIS environment. However, because it did not consider CP932 and
GAIJI, it is not very popular.

"JIS X 0213 bridge" needs last one meter.

To solve the problem, Jacode4e proposes CP932X [shi:pi:kju:san'nikai].

CP932X implements JIS X 0213 over CP932.

We can continue to use CP932 data, application programs, databases, and
networks using CP932X.

If you need round-trip conversion, you had better use Jacode4e::RoundTrip
module.

WHAT IS "CP932X"?

  • "cp932x" as mnemonic

  • CP932X is CP932

  • Pronounce [si: pi: nain thri: tu: kai] in English

  • Pronounce [shi: pi: kju: san' ni kai] in Japanese

  • [si: pi: nain thri: tu: iks] is reserved for Microsoft Corporation ;-P

  • CP932 upper compatible

  • Supports JIS X 0213 character set

  • Used ghost character "\x9C\x5A" as single shift code

  • Used "\x9C\x5A\x9C\x5A" for single "\x9C\x5A"

  • You can use private use characters you made

  • You can use your operating system, network, and database.

  • In most cases, application programs can be used as it is.

WHAT IS "UTF-8-SPUA-JP"?

  • "utf8jp" as mnemonic

  • UTF-8-SPUA-JP is UTF-8

  • Internal character encoding of Jacode4e and Jacode4e::RoundTrip, universally

  • Implements JIS X 0213 character set on to Unicode Supplementary Private Use Area-A

  • Code point ordered by JIS level, plane, row, cell

  • Uniformly length encoding

  • No grapheme clustering, one character by uniquely code point

DEPENDENCIES

This software requires perl version 5.00503 or later to run. (All of Perl4 users in the world, pardon me!)

SOFTWARE LIFE CYCLE

                                       Jacode.pm
                  jcode.pl  Encode.pm  jacode.pl  Jacode4e  Jacode4e::RoundTrip
--------------------------------------------------------------------------------
1993 Perl4.036       |                     |                                    
  :     :            :                     :                                    
1999 Perl5.00503     |                     |         |               |          
2000 Perl5.6         |                     |         |               |          
2002 Perl5.8         |         Born        |         |               |          
2007 Perl5.10        V          |          |         |               |          
2010 Perl5.12       EOL         |         Born       |               |          
2011 Perl5.14                   |          |         |               |          
2012 Perl5.16                   |          |         |               |          
2013 Perl5.18                   |          |         |               |          
2014 Perl5.20                   |          |         |               |          
2015 Perl5.22                   |          |         |               |          
2016 Perl5.24                   |          |         |               |          
2017 Perl5.26                   |          |         |               |          
2018 Perl5.28                   |          |        Born            Born        
2019 Perl5.30                   |          |         |               |          
2020 Perl5.32                   :          :         :               :          
2030 Perl5.52                   :          :         :               :          
2040 Perl5.72                   :          :         :               :          
2050 Perl5.92                   :          :         :               :          
2060 Perl5.112                  :          :         :               :          
2070 Perl5.132                  :          :         :               :          
2080 Perl5.152                  :          :         :               :          
2090 Perl5.172                  :          :         :               :          
2100 Perl5.192                  :          :         :               :          
2110 Perl5.212                  :          :         :               :          
2120 Perl5.232                  :          :         :               :          
  :     :                       V          V         V               V          
--------------------------------------------------------------------------------

SOFTWARE COVERAGE

When you lost your way, you can see this matrix and find your way.

Skill/Use  Amateur    Semipro    Pro        Enterprise  Enterprise(round-trip)
-------------------------------------------------------------------------------
Expert     jacode.pl  Encode.pm  Encode.pm  Jacode4e    Jacode4e::RoundTrip
-------------------------------------------------------------------------------
Middle     jacode.pl  jacode.pl  Encode.pm  Jacode4e    Jacode4e::RoundTrip
-------------------------------------------------------------------------------
Beginner   jacode.pl  jacode.pl  jacode.pl  Jacode4e    Jacode4e::RoundTrip
-------------------------------------------------------------------------------

Why CP932X born?

In order to know why CP932X exists the way it is(or isn't), one must first know why CP932X born.

Q1) Is CCS of JIS X 0208 enough?
A1) No. Often we require GAIJI.

Q2) Is CCS of JIS X 0213 enough?
A2) It's not perfect, but enough for many people.

Q3) Is CES by UTF-8 good?
A3) No. In Japanese information processing, it's unstable and not popular still now.

Q4) Is CES by Shift_JIS-2004 good?
A4) No. Because Shift_JIS-2004 cannot support very popular CP932 and your GAIJI. We need a realistic solution to solving real problem.

Q5) Is escape sequence good idea to support CCS of JIS X 0213?
A5) No. Because the programming is so hard.

Q6) Which character is best as single shift code to support CCS of JIS X 0213?
  -- The single shift code must be a DBCS code, because DBCS field cannot store SBCS code in some cases
  -- Moreover, all GAIJI code points must be yours
  -- The impact of this solution must be minimum
A6) I select 1-55-27 as single shift code. It is ghost character and not used by nobody.

AUTHOR

INABA Hitoshi <ina@cpan.org> in a CPAN

This project was originated by INABA Hitoshi.

LICENSE AND COPYRIGHT

This software is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

SEE ALSO

CPGID 00290
https://www-01.ibm.com/software/globalization/cdra/
https://www-01.ibm.com/software/globalization/cp/cp00290.html
ftp://ftp.software.ibm.com/software/globalization/gcoc/attachments/CP00290.pdf
ftp://ftp.software.ibm.com/software/globalization/gcoc/attachments/CP00290.txt

HiRDB Datareplicator Version 8 manuals, Hitachi, Ltd.
http://itdoc.hitachi.co.jp/manuals/3020/3020636050/W3600001.HTM
http://itdoc.hitachi.co.jp/manuals/3020/3020636050/W3600166.HTM
http://itdoc.hitachi.co.jp/manuals/3020/30203J3820/ISUS0268.HTM
http://itdoc.hitachi.co.jp/manuals/3000/30003D5820/CLNT0235.HTM

Linkexpress, FUJITSU LIMITED
http://software.fujitsu.com/jp/manual/manualfiles/M080093/J2X15930/03Z200/index.html
http://software.fujitsu.com/jp/manual/manualfiles/M080093/J2X15930/03Z200/unyo05/unyo0413.html
http://software.fujitsu.com/jp/manual/manualfiles/m130010/b1fw5992/01z200/b5992-c-00-00.html

iDIVO Ver.1.4.0
https://www.hulft.com/shukka/files/iDIVO/SP-DV1-CC-02-01.pdf

cp932 to Unicode table
ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP932.TXT
https://support.microsoft.com/ja-jp/help/170559/prb-conversion-problem-between-shift-jis-and-unicode

Shift_JIS-2004 to Unicode table
http://x0213.org/codetable/sjis-0213-2004-std.txt

IBM Japanese Graphic Character Set, Kanji DBCS Host and DBCS - PC
https://www-01.ibm.com/software/globalization/cdra/
ftp://ftp.software.ibm.com/software/globalization/gcoc/attachments/CP00300.pdf

IBM Kanji code list
N:GC18-2040-3

KEIS code book, Culti Co.,Ltd.
http://www.culti.co.jp/2016/02/01/%e3%82%ab%e3%83%ab%e3%83%81%e7%99%ba%e8%a1%8c%e6%9b%b8%e7%b1%8d/

JIS X 0208 (1990) to Unicode
ftp://ftp.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0208.TXT

Appendix B.2 Character code differences
http://itdoc.hitachi.co.jp/manuals/3020/3020759580/G5950334.HTM

Appendix E Handling of character codes in PDE - Form Designer (applies only to distributed type PDE)
http://itdoc.hitachi.co.jp/manuals/3020/30203p0360/PDEF0203.HTM

HITAC Character code table (KEIS83)
Document number 8080-2-100-10

JEF code book, Culti Co.,Ltd.
http://www.culti.co.jp/2016/02/01/jef%e3%82%b3%e3%83%bc%e3%83%89%e3%83%96%e3%83%83%e3%82%af/

Linkexpress operation manual J2X1-5930-03Z2(00) FUJITSU LIMITED
http://software.fujitsu.com/jp/manual/manualfiles/M080093/J2X15930/03Z200/index.html
http://software.fujitsu.com/jp/manual/manualfiles/M070086/J2X15930/01Z200/unyo05/unyo0416.html
http://software.fujitsu.com/jp/manual/manualfiles/M070086/J2X15930/01Z200/unyo05/unyo0420.html
http://software.fujitsu.com/jp/manual/manualfiles/M070086/J2X15930/01Z200/unyo05/unyo0421.html
http://software.fujitsu.com/jp/manual/manualfiles/m120010/b1fw5691/05z200/index.html
http://software.fujitsu.com/jp/manual/manualfiles/m120010/b1fw5691/05z200/index.html
http://software.fujitsu.com/jp/manual/manualfiles/m120010/b1fw5691/05z200/index.html
http://software.fujitsu.com/jp/manual/manualfiles/m120010/b1fw5691/05z200/index.html
http://software.fujitsu.com/jp/manual/manualfiles/m120010/b1fw5691/05z200/b5691-g-00-00.html

hidekatsu-izuno/jef4j
https://github.com/hidekatsu-izuno/jef4j

JHTc(JHT command edition)
http://www.vector.co.jp/soft/winnt/util/se094205.html

FACOM JEF Character code index dictionary
Manual code 99FR-0012-3

JIPS code book, Culti Co.,Ltd.
http://www.culti.co.jp/2016/02/01/jips%e3%82%b3%e3%83%bc%e3%83%89%e3%83%96%e3%83%83%e3%82%af/

NEC Corporation Standard character set dictionary <BASIC>
ZBB10-3

NEC Corporation Standard character set dictionary <EXTENSION>
ZBB11-2

ClearPath Enterprise Servers MultiLingual System Administration, Operations, and Programming Guide ClearPath MCP 15.0 April 2013 8600 0288-308
https://public.support.unisys.com/aseries/docs/ClearPath-MCP-16.0/PDF/86000288-308.pdf

Heterogeneous database cooperation among heterogeneous OS environments
http://www.unisys.co.jp/tec_info/tr56/5605.htm

UNISYS_SJIS KANJI CONVERT(DOS ver)
https://www.vector.co.jp/soft/dos/util/se238607.html

ANSI X3.4-1968 (US-ASCII) with 0x60/0x27 as left/right single quotation mark to Unicode
http://www.unicode.org/Public/MAPPINGS/VENDORS/MISC/US-ASCII-QUOTES.TXT

JIS X 0201 (1976) to Unicode 1.1 Table
http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0201.TXT

JIS X 0208 (1990) to Unicode
http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0208.TXT

JIS X 0212 (1990) to Unicode
http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/JIS0212.TXT

UTF-8, a transformation format of ISO 10646
https://www.rfc-editor.org/rfc/rfc3629.txt

Kanji shift code
https://ja.wikipedia.org/wiki/%E6%BC%A2%E5%AD%97%E3%82%B7%E3%83%95%E3%83%88%E3%82%B3%E3%83%BC%E3%83%89

CJKV Information Processing
https://resources.oreilly.com/examples/9781565922242/tree/master/AppQ/78-vs-83-1.sjs
https://resources.oreilly.com/examples/9781565922242/tree/master/AppQ/78-vs-83-2.sjs
https://resources.oreilly.com/examples/9781565922242/tree/master/AppQ/78-vs-83-3.sjs
https://resources.oreilly.com/examples/9781565922242/tree/master/AppQ/78-vs-83-4.sjs
https://resources.oreilly.com/examples/9781565922242/tree/master/AppQ/83-vs-90-1.sjs
https://resources.oreilly.com/examples/9781565922242/tree/master/AppQ/83-vs-90-2.sjs
https://resources.oreilly.com/examples/9781565922242/tree/master/AppQ/TJ2.sjs
https://resources.oreilly.com/examples/9781565922242/tree/master/AppQ/TJ3.sjs
https://resources.oreilly.com/examples/9781565922242/tree/master/AppQ/TJ4.sjs

Very old fj.kanji discussion
http://www.ie.u-ryukyu.ac.jp/~kono/fj/fj.kanji/index.html

jcode.pl: Perl library for Japanese character code conversion, Kazumasa Utashiro
ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/
http://web.archive.org/web/20090608090304/http://srekcah.org/jcode/
ftp://ftp.oreilly.co.jp/pcjp98/utashiro/
http://mail.pm.org/pipermail/tokyo-pm/2002-March/001319.html
https://twitter.com/uta46/status/11578906320

jacode - Perl program for Japanese character code conversion
https://metacpan.org/search?q=jacode.pl

Jacode4e - jacode.pl-like program for enterprise
https://metacpan.org/pod/Jacode4e

Jacode4e::RoundTrip - Jacode4e for round-trip conversion in JIS X 0213
https://metacpan.org/pod/Jacode4e::RoundTrip

Modern::Open - Autovivification, Autodie, and 3-args open support
https://metacpan.org/pod/Modern::Open

BackPAN
http://backpan.perl.org/authors/id/I/IN/INA/

ACKNOWLEDGEMENTS

I could make this software by good luck. I thank all stakeholders.

I received character code table of KEIS, JEF, and JIPS by electronic data
from Culti Co.,Ltd. Moreover, Culti Co.,Ltd. has allowed me to use it to
make open source software.

I thank Culti Co.,Ltd. once again.

HELLO WORLD

To support JIS X 0213:2004,

    Using ghost character 1-55-27(it's me!),

Found by JIS X 0208:1997,

    Was born in JIS C 6226-1978.

Hello world,

    What do we hack, today?

               -- 1-55-27, 2018-01-27