NAME

    jacode - Perl program for Japanese character code conversion

VERSION

    2.13.4.32

SYNOPSIS

    Works like 'jcode.pl' in your script:

      require 'jacode.pl';

           ($subref, $got_INPUT_encoding) = jacode::convert(\$line, $OUTPUT_encoding, $INPUT_encoding [, $option])
                      $got_INPUT_encoding = jacode::convert(\$line, $OUTPUT_encoding, $INPUT_encoding [, $option])
                  ($esc_DBCS, $esc_ASCII) = jacode::get_inout($line)
      ($esc_DBCS_fully, $esc_ASCII_fully) = jacode::jis_inout([$esc_DBCS [, $esc_ASCII]])
             ($matched_length, $encoding) = jacode::getcode(\$line)
                                $encoding = jacode::getcode(\$line)
                                            jacode::init()

    Works as 'pkf' command on the command line (shows help):

      $ perl jacode.pl

    Also available as a Perl 5 module (Jacode.pm):

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

DESCRIPTION

    jacode.pl converts Japanese text between the four encodings in common
    use: JIS (ISO-2022-JP), Shift_JIS (CP932), EUC-JP, and UTF-8.

    The API is intentionally identical to jcode.pl by Kazumasa Utashiro, so
    existing scripts that use jcode.pl can switch to jacode.pl by changing
    only the require line.

    Key features:

    * jcode.pl upper compatible (drop-in require replacement)
    * pkf command upper compatible (Perl Kanji Filter)
    * Perl 4 script and also Perl 5 script (Perl 4.036 through latest)
    * Supports halfwidth KATAKANA (JIS X0201) <-> fullwidth (JIS X0208)
    * Supports UTF-8 via CP932-to-Unicode mapping table
    * Falls back to Encode::from_to() for non-Japanese encodings (Perl 5.8+)
    * Detects encoding automatically (getcode)
    * Cache-based single-character conversion for speed

ENCODING NAMES

    The following encoding name strings are used throughout the API:

      'jis'   ISO-2022-JP (JIS X0208, also accepts JIS X0212 / JIS X0213)
      'sjis'  Shift_JIS / CP932 (Microsoft Windows)
      'euc'   EUC-JP
      'utf8'  UTF-8 (RFC 3629)

API REFERENCE

  jacode::convert(\$string, $output, [$input, [$option]])

    Convert $string in-place from $input encoding to $output encoding.
    If $input is omitted or undef, encoding is auto-detected via getcode().

    $option:
      'z'   convert halfwidth kana to fullwidth (h2z) before conversion
      'h'   convert fullwidth kana to halfwidth (z2h) before conversion

    In list context returns ($subref, $detected_input_encoding).
    In scalar context returns $detected_input_encoding.
    Returns (undef, undef) when encoding cannot be determined.
    Returns (undef, 'binary') when input is binary.

    Example:
      require 'jacode.pl';
      while (<STDIN>) {
          jacode::convert(\$_, 'euc', 'sjis');
          print;
      }

  jacode::getcode(\$string)

    Detect the encoding of $string.
    Returns encoding name in scalar context, ($matched_bytes, $name) in list.
    Returns undef for pure ASCII.  Returns 'binary' for unrecognised bytes.

  jacode::jis($string [, $input [, $option]])
  jacode::euc($string [, $input [, $option]])
  jacode::sjis($string [, $input [, $option]])
  jacode::utf8($string [, $input [, $option]])

    Return-by-value interfaces.  Return a converted copy without modifying
    the original.

    Example:
      $euc_line = jacode::euc($sjis_line, 'sjis');

  jacode::jis_inout([$esc_DBCS [, $esc_ASCII]])

    Get or set the JIS escape sequences.  Common $esc_DBCS values:
      'B'  JIS X0208-1983 (default)
      '@'  JIS C6226-1978
      '&'  JIS X0208-1990
      'O'  JIS X0213:2000
      'Q'  JIS X0213:2004

  jacode::h2z_jis / h2z_euc / h2z_sjis / h2z_utf8 (*string)

    Convert halfwidth KATAKANA to fullwidth in-place.

  jacode::z2h_jis / z2h_euc / z2h_sjis / z2h_utf8 (*string)

    Convert fullwidth KATAKANA to halfwidth in-place.

  jacode::tr(*string, $from, $to [, $option])

    DBCS-aware transliteration.  $option 'd' deletes unmatched characters.

  jacode::cache() / jacode::nocache() / jacode::flush()

    Enable (default) / disable / clear the conversion cache.

JCODE.PL COMPATIBILITY

    All jacode:: subroutines are also available as jcode:: aliases:

      require 'jacode.pl';
      &jcode'convert(*line, 'euc');   # Perl 4 style
      jcode::convert(\$line, 'euc');  # Perl 5 style

PKF COMMAND

    Running jacode.pl directly invokes the pkf (Perl Kanji Filter) command:

      perl jacode.pl -es file.txt      # EUC-JP to SJIS
      perl jacode.pl -sw file.txt      # SJIS to UTF-8
      perl jacode.pl -me file.txt      # auto-detect input, output EUC-JP
      perl jacode.pl                   # show help

INSTALLATION

    To use jacode.pl as a library, copy it to any directory in @INC.
    To run the test suite: make test

SECURITY

    See SECURITY.md for the vulnerability reporting policy.

DEPENDENCIES

    Perl 4.036 or later.
    Optional (Perl 5.8+): Encode.pm for non-Japanese encoding fallback.

AUTHOR

    Copyright (c) 1992-2002 Kazumasa Utashiro
    Copyright (c) 2010, 2011, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2022, 2023, 2026 INABA Hitoshi <ina@cpan.org>

LICENSE

    Same terms as Perl itself.

SEE ALSO

    jcode.pl by Kazumasa Utashiro
    https://metacpan.org/author/UTASHIRO

    Jacode (this distribution, Perl 5 module interface)
    https://metacpan.org/dist/Jacode

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

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

    mb - multibyte string library for Perl 4 through latest
    https://metacpan.org/release/mb

    UTF8-R2 - use UTF-8 in older Perl
    https://metacpan.org/release/UTF8-R2
