my $str = $utf8_str; Encode::from_to($str, 'utf8', 'cp949');
use Text::Iconv; $c = Text::Iconv->new("utf8","cp949"); $_data = $c->convert( $str_utf8);
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; }