#keywords Encode,Perl,UTF-8 [[TableOfContents]] == UTF-8 to CP949 == use Encode; {{{#!perl my $str = $utf8_str; Encode::from_to($str, 'utf8', 'cp949'); }}} use Text::Iconv; {{{#!perl use Text::Iconv; $c = Text::Iconv->new("utf8","cp949"); $_data = $c->convert( $str_utf8); }}} == UTF-8 Encode & Decode == {{{#!perl sub urlencode { my $s = shift; $s =~ s/ /+/g; $s =~ s/([^A-Za-z0-9\+-])/sprintf("%%%02X", ord($1))/seg; return $s; } sub urldecode { my $s = shift; $s =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg; $s =~ s/\+/ /g; return $s; } # advanced sub urldecode { #phase 1 my $s = shift; $s =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg; $s =~ s/\+/ /g; #phase 2 use URI::Escape qw(uri_unescape); use utf8; my $x = my $y = uri_unescape($s); return $x if utf8::decode($x); return $y; } }}} == 기타 == http://gypark.pe.kr/wiki/Perl/%EB%AC%B8%EC%9E%90%EC%97%B4%EC%9D%B8%EC%BD%94%EB%94%A9