Converting character code

Top Japanese page




Overview

Convert Japanese characters.

Flow

  1. Load Jcode
  2. Convert to the code you want

Sample code

 use Jcode;
 
 my $string = "日本語文字列";
 
 print jcode($string)->utf8;

Description of the code

 use Jcode;

Load Jcode.

 my $string = "日本語文字列";

$string containts Japanese characters. This characters will be converted to any other Japanese code such as Shift_JIS, EUC-JP, JIS or UTF-8.

 print jcode($string)->utf8;

In this example, $string is converted to utf8. To convert Shift_JIS, EUC-JP, ISO-20022-JP(JIS), the following methods are used respectively.

 jcode($string)->sjis;
 
 jcode($string)->euc;
 
 jcode($string)->jis;

Just to convert without displaying,

 my $new_string = jcode($string)->utf8;

it can be done as above.