NAME
    Mail::Message::Encode - encode/decode/charset conversion routines.

SYNOPSIS
        use Mail::Message::Encode;
        my $obj = new Mail::Message::Encode;
        $str    = $obj->encode_mime_string($str, $encode, $out_code, $in_code);
        $self->set($str);

    It is not recommended but if you use old style, import required
    function:

        use Mail::Message::Encode qw(STR2EUC);
        my $euc_string = STR2EUC($string);

DESCRIPTION
METHODS
  new()
    constructor.

  detect_code($str)
    speculate the code of $str string. $str is checked by Unicode::Japanese.
    Unicode::Japanes::getcode() can detect the follogin code: jis, sjis,
    euc, utf8, ucs2, ucs4, utf16, utf16-ge, utf16-le, utf32, utf32-ge,
    utf32-le, ascii, binary, sjis-imode, sjis-doti, sjis-jsky.

    "CAUTION": we handle only Japanese and English.

  convert($str, $out_code, $in_code)
    convert $str to $out_code code. $in_code is used as a hint.

  convert_str_ref($str_ref, $out_code, $in_code)
    convert string reference $str_str to $out_code code. $in_code is used as
    a hint.

  run_in_code($proc, $s, $args, $out_code, $in_code)
    run $proc($s) under $out_code environment. So, execute $proc like this.

        my $obj         = new Mail::Message::Encode;
        my $conv_status = $obj->convert_str_ref($s, $out_code, $in_code);

        &$proc($s, $args);

    It means run $proc() after $s is converted to $out_code code.

UTILITIES
  is_iso2022jp_string($buf)
    $buf looks like Japanese or not ?

BACKWARD COMPATIBILITY
  STR2EUC($str)
    convert $str to japanese EUC code.

  STR2JIS($str)
    convert $str to japanese JIS code.

  STR2SJIS($str)
    convert $str to japanese SJIS code.

MIME ENCODE
  encode_mime_string($str, $encode, $out_code, $in_code)
    encode string $str to encoding system $encode with output code
    $out_code. $in_code is used as a hint.

  base64($str, $out_code, $in_code)
    encode $str by base64 with out code out_code. $in_code is use as a hint.

  qp($str, $out_code, $in_code)
    encode $str by quoted-printable with out code out_code. $in_code is use
    as a hint.

  decode_mime_string(string, [$options])
    decode a base64/quoted-printable encoded string to a plain message. The
    encoding method is automatically detected.

    $options is a HASH REFERENCE. You can specify the charset of the string
    to return by $options->{ charset }.

    [reference] RFC1554 says:

          reg#  character set      ESC sequence                designated to
          ------------------------------------------------------------------
          6     ASCII              ESC 2/8 4/2      ESC ( B    G0
          42    JIS X 0208-1978    ESC 2/4 4/0      ESC $ @    G0
          87    JIS X 0208-1983    ESC 2/4 4/2      ESC $ B    G0
          14    JIS X 0201-Roman   ESC 2/8 4/10     ESC ( J    G0
          58    GB2312-1980        ESC 2/4 4/1      ESC $ A    G0
          149   KSC5601-1987       ESC 2/4 2/8 4/3  ESC $ ( C  G0
          159   JIS X 0212-1990    ESC 2/4 2/8 4/4  ESC $ ( D  G0
          100   ISO8859-1          ESC 2/14 4/1     ESC . A    G2
          126   ISO8859-7(Greek)   ESC 2/14 4/6     ESC . F    G2

DEBUG
  dump_string($str)
    dump $str as the style by "od -a".

CODING STYLE
    See "http://www.fml.org/software/FNF/" on fml coding style guide.

AUTHOR
    Ken'ichi Fukamachi

COPYRIGHT
    Copyright (C) 2002,2003,2004,2005,2011 Ken'ichi Fukamachi

    All rights reserved. This program is free software; you can redistribute
    it and/or modify it under the same terms as Perl itself.

HISTORY
    Mail::Message::Encode first appeared in fml8 mailing list driver
    package. See "http://www.fml.org/" for more details.

