̾



̾

Jcode - ܸʸϥɥ


 use Jcode;
 # 
 # ż椫
 Jcode::convert($str, $ocode, $icode, "z");
 # ⤷ϥ֥Ȼظǡ
 print Jcode->new($str)->h2z->tr($from, $to)->utf8;


Jcode.pmϥ֥ŪʥץȽ褫Υץξ ݡȤƤޤ֥ŪʥץȤФʴǡ

  $iso_2022_jp = Jcode->new($str)->h2z->jis;

ꥨ쥬ȤǤ礦

  $iso_2022_jp = $str;
  &jcode::convert(\$iso_2022_jp, 'jis', &jcode::getcode(\$str), "z");

֥Ȥߤ̵ͤΤˡJcode.pmϤޤgetcode() convert()򥵥ݡȤƤޤ

PerlΥС5.8.1ʾʤ顢JcodeϡPerl 5.8ʹߤɸŪʸ ϥɥ⥸塼Ǥthe Encode manpageΥåѡȤƿ񤤤ޤ


᥽å

ä˸ڤʤ¤ꡢǵ󤲤᥽åɤJcode֥Ȥ֤ޤ

󥹥ȥ饯

$j = Jcode->new($str [, $icode])
$strJcode֥$jޤŪ$icode򥻥åȤʤС ϥɤϼưŪȽꤵޤѲǽʸˤĤƤϡ getcode򻲾ȤƤ

Perl 5.8.1ʹߤǤϡ$icodeˤthe Encode manpageǤ ɤʥ󥳡ǥ̾Ȥޤ

  $j = Jcode->new($european, 'iso-latin1');

֥Ȥʸ󲽤ȡEUCѴ줿ʸ֤ޤǤ print $j->eucȤˡprint $jȤǤޤ

եϤ
顼ͤˡʲΤ褦˥ե󥹤Ϥޤ
 Jcode->new(\$str);

Ϥۤξ֤󤷤ޤȤơ$strͤΤΤ Ѵޤʤ̣$strjcode֥Ȥ``tie''ΤǤˡ

$j->set($str [, $icode])
$jʸ$str򥻥åȤޤ֤Jcode֥ȤȤȤ Ǥʥ֥Ȥ֤ȥˤʤޤˡ
 # mailboxSJISѴ
 my $jconv = new Jcode;
 $/ = 00;
 while(<>){
     print $jconv->set(\$_)->mime_decode->sjis;
 }

$j->append($str [, $icode]);
$jʸ$sträޤ

$j = jcode($str [, $icode]);
Jcode->new() û̷ʲΤ褦ˤǤޤ
 $sjis = jcode($str)->sjis;

ʸΥ󥳡

̤ˡ$j->encodedȤ뤳ȤencodedѴ줿ʸޤ

$sjis = $j->sjis
$euc = $j->euc
$jis = $j->jis
$sjis = $j->sjis
$ucs2 = $j->ucs2
$utf8 = $j->utf8
Ǥ礦 WYCIWYG = What you code is what you get :)

$iso_2022_jp = $j->iso_2022_jp
$j->h2z->jisƱǤ Ⱦѥʤ϶ŪѤѴޤ

Perl 5.8.1ʹߤǤϡEncodeݡȤɤʥ󥳡ǥ̾ ꥢǤѤǤޤ㤨С

  $european = $j->iso_latin1; # ᥽å̾Ѥ'-''_'֤ޤ

the Encode::Encoder manpageƱȤäƤޤ

$j->fallback($fallback)
Perl 5.8.1ʹߤǤϡJcodeʸUTF-8ݻޤ ->encoding >˥ޥåפǤʤʸ'?'֤ޤ the Encode manpageǤɸưǤ
  my $unistr = "\x{262f}"; # ۥޡ
  my $j = jcode($unistr);  # $j->euc η̤ '?' 

ο񤤤ϡthe Encode manpageƱ͡եХåꤹ뤳ȤѹǤޤ ͤthe Encode manpageΤΤȰǤصΤᡢJcode::FB_PERLQQ Jcode::FB_XMLCREFJcode::FB_HTMLCREFthe Encode manpageΤؤ ꥢˤʤäƤޤ

  print $j->fallback(Jcode::FB_PERLQQ)->euc;   # '\x{262f}'
  print $j->fallback(Jcode::FB_XMLCREF)->euc;  # '&#x262f;'
  print $j->fallback(Jcode::FB_HTMLCREF)->euc; # '&#9775;'

Хѿ$Jcode::FALLBACK˥ǥեȤΥեХåݻ ƤޤΤǡͤ뤳ȤǥС饤ɤǤޤ

  $Jcode::FALLBACK = Jcode::FB_PERLQQ; # ǥեȤΥեХåޤ

[@lines =] $jcode->jfold([$width, $newline_str, $kref])
$widthʥǥեȡ72jcodeʸιԤޤ֤ޤ $widthϡȾѡʸοǤʸ2ʸȤƥȤޤ

$newline_strʥǥեȤ``\n''ˤǻꤵ줿ʸäޤ ޤ֤줿ԤꥹȤ֤ޤ

Perl 5.8.1ʹߤ3ܤΰ$krefEUCʸե󥹤 ϤȤǡʰŪʹƬ§ʤ֤鲼ˤԤޤ

$length = $jcode->jlength();
ХĹǤϤʤʸʸȤƿʸ֤ޤ

MIME::Base64Ȥ᥽å

Υ᥽åɤȤˤϡthe MIME::Base64 manpageɬפǤ󥹥ȡñ

   perl -MCPAN -e 'CPAN::Shell->install("MIME::Base64")'

ȤޤȤPerl5.6ʹߤǤʤ顢the MIME::Base64 manpage Хɥ뤵ƤΤǡ󥹥ȡɬפϤޤ

$mime_header = $j->mime_encode([$lf, $bpl])
$strRFC1522ˤMIME-HeaderѴޤ$lfꤹȡ Ԥޤ֤$lfȤޤʥǥեȡ\nˡ $bplꤹȡޤ֤Хȿ$bplȤޤʥǥեȡ76 οͤ76ʲǤʤФʤޤˡ

Perl 5.8.1ʹߤǤϡʲΤ褦ˤƤMIME Header󥳡ɤǤޤ

  $mime_header = $j->MIME_Header;

ξ$mime_headerͤMIME-B-encoded UTF-8ˤʤޤ $j->mime_encode()MIME-B-encoded ISO-2022-JP֤ޤ ǶΤۤȤɤΥ᡼顼Ϥɤ⥵ݡȤƤޤ

$j->mime_decode;
Jcode֥ȤʸMIME-HeaderǥɤޤPerl 5.8.1 ʹߤʤ顢ʲΤ褦ˤƱȤǤޤ
  Jcode->new($str, 'MIME-Header');

ξ硢ISO-2022-JPǤϤʤUTF-8ʤɤˤбƤꡢ MIME B EncodingΤߤʤ餺MIME Q EncodingˤбƤ ΤǡPerl 5.8.1ʹߤǤФȤ٤Ǥ礦

Ⱦ

$j->h2z([$keep_dakuten])
X201ʡȾѡˤX208ʡѡˤѴޤ $keep_dakuten˿ͤ򥻥åȤȡ򤽤Τޤޤˤޤ (ϤĤޤꡢ֥ܡפϡ֥פѴ줺ˤΤޤ ˤʤȤȤǤ)

$j->nmatch̤ƥޥåǤޤ

$j->z2h
X208ʡѡˤX201ʡȾѡˤѴޤ

$j->nmatch̤ƥޥåǤޤ

ɽߥ졼

->m()->s()ȤˤϡPerl 5.8.1ʹߤ ɬפǤ

$j->tr($from, $to, $opt);
Jcode֥Ȥtr/$from/$to/ŬѤޤ$from$to EUC-JPʸǤPerl 5.8.1ʹߤǤϡflagդUTF-8ʸ դޤ

$opt򥻥åȤȡtr/$from/$to/$optŬѤޤ$opt 'c''d'뤤ϤȤ߹碌ǤʤФʤޤ

$j->nmatch̤ƥޥåǤޤ

Perl 5.8.1ʹߤǤϡtrη˸Τä->error_tr̤ơ $@Ǥޤ

ʲΥ᥽åɤPerl 5.8.1ʹߤǤΤѲǽǤ

$j->s($patter, $replace, $opt);
ġs/$pattern/$replace/$optŬѤޤ$optɽץ ƱǤɽΥץˤĤƤthe perlre manpage򻲾Ȥ

$j->tr()$j->s()ϤΥ֥ȼȤ֤Τǡ ʲΤ褦ϢǤޤ

  $j->tr("A-Z", "a-z")->s("foo", "bar");

[@match = ] $j->m($pattern, $opt);
m/$patter/$optŬѤޤΥ᥽åɤϡɥ֥Ȥ֤ʤ Τǡ$j->s()Τ褦˥᥽åɤϢǤʤȤդƤ

ɽη˸Τä硢->error_m->error_s̤ $@Ǥޤ

󥹥ѿ

⤷Jcode֥ȤΥ󥹥ѿ˥ʤ顢ľܤ ˥ΤǤϤʤ᥽åɤѤޤ礦ʤ줾OOP Ǥˡ

ͤޤǤˡJcodeϡʰŪˡǤ˥ϥåե󥹤ˡ ե󥹤ȤȤǡԡɤŬƤޤʼºݤΤȤ ᥽åɤȤ¤ꤳΤȤΤɬפϤޤ ⤦ ޤOOPʤΤǤˡ

Perl 5.8.1ʹߤǤϡϥåե󥹤Ȥ褦ѹޤ ˤꡢJcodeγĥϤΤñˤʤޤ

$j->r_str
EUCʸؤΥե󥹡

Perl 5.8.1ʹߤǤUTF-8ե饰ΩäUTF-8ʸؤΥե󥹤Ǥ

$j->icode
ľˤʸɡ

$j->nmatch
ޥå$j->trȤäȤˡ


֥롼

($code, [$nmatch]) = getcode($str)
$strʸɤ֤ޤ֤륳ɤϰʲ̤Ǥ
 ascii   Ascii ܸ쥳ɤޤޤʤ
 binary  Binary ʥƥȥեǤϤʤ
 euc     EUC-JP
 sjis    SHIFT_JIS
 jis     JIS (ISO-2022-JP)
 ucs2    UCS2 (Raw Unicode)
 utf8    UTF8

顼ƥȤ󥳥ƥȤȤȡʸʬ ɤĤäΤ֤ޤǽҤ٤褦ˡ$str\$str Ǥ⹽ޤ

jcode.pl ѼԤء δؿjcode::getcode()100%̸ߴ ޤޤۤ100%

 * ͤΤȤν֤ϵդȤʤޤ
   jcode::getcode()$nmatchǽ֤ޤ
 * jcode::getcode()ϡEUCʸSJISʸοȤ'undef'
   ֤ޤ Jcode::getcode()EUC֤ޤJcode.pmˤ
   ֤ʤǤ

Jcode::convert($str, [$ocode, $icode, $opt])
$str$ocodeǻꤷʸɤѴޤ$icodeꤹȡ ʸgetcode()ǥåˡ$icodeȲꤷޤ ǽҤ٤褦ˡ$str\$strǤ⹽ޤ

jcode.pl ѼԤء δؿjcode::convert()100%̸ߴ ޤ


Х

Perl5.8.1ʹߤξ硢Jcodethe Encode manpageΥåѡȤƿ񤤤ޤ ĤޤꡢJcodeEncodeΥХαƶޤ


ռ

Υѥåϡưǥ󤽤ƥɤ¿ǡ <utashiro@iij.ad.jp>Perl4饤֥jcode.pläƤޤ

<ohzaki@iod.ricoh.co.jp>ϡȯ˽ʳ ɽ᤭򤷤Ƥޤ

makamaka@donzoko.net JEncode ˤϡJcodeEncodeɤͻ礵 礭ʷޤޤܸޥ˥奢£ ޤ

Jcode ML <jcode5@ring.gr.jp>γ󡣤ãʤˤϡ ޤǴʤäȤǤ礦


the Encode manpage

http://www.iana.org/assignments/character-sets


Copyright 1999-2005 Dan Kogai <dankogai@dan.co.jp>

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

 ̾