- 论坛徽章:
- 1
|
怎么把utf ->gb2312 and gb2312 -> utf
use Unicode::MapUTF8 qw(to_utf8 from_utf8 utf8_supported_charset);
# Convert a string in 'gb2312' to 'UTF8'
my $output = to_utf8({ -string =>; 'An example', -charset =>; 'gb2312' });
# Convert a string in 'UTF8' encoding to encoding 'gb2312'
my $other = from_utf8({ -string =>; 'Other text', -charset =>; 'gb2312' });
=========================================
上面是參考CPAN 的說明..
試試看上面這個module,如果不行再用下面的方式設定新的charset
,注意Unicode::MapUTF8必須要上search.cpan.org抓下來..
Try It....如果是Perl 5.8以上,default有個encode的module..
怎麼用請自行研究..我沒用過..
=========================================
# List available character set encodings
my @character_sets = utf8_supported_charset;
# Add a character set alias
utf8_charset_alias({ 'ms-japanese' =>; 'sjis' });
# Convert between two arbitrary (but largely compatible) charset encodings
# (SJIS to EUC-JP)
my $utf8_string = to_utf8({ -string =>;$sjis_string, -charset =>; 'sjis'});
my $euc_jp_string = from_utf8({ -string =>; $utf8_string, -charset =>; 'euc-jp' })
# Verify that a specific character set is supported
if (utf8_supported_charset('ISO-8859-1') {
# Yes
} |
|