kamalakar has asked for the wisdom of the Perl Monks concerning the following question:
sub convertoUtf{ my $your_data = shift; my $encoding = 'ISO-8859-1'; if ($encoding ne 'UTF-8'){ my $ustr = Unicode::String->new(); if ($encoding eq 'UTF-16'){ $ustr->utf16( $your_data ); }else{ my $map = Unicode::Map->new( $encoding ); if (! $map ){ # Deal with the unsupported encoding somehow; # you probably want to have a message like this: # "Unsupported XML encoding: $encoding"); } $ustr->utf16( $map->to_unicode( $your_data ) ); } $your_data = $ustr->utf8(); } return $your_data; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: convert a string(which contains the contents of a file) into UTF-8 encoding
by ikegami (Patriarch) on Sep 26, 2009 at 01:55 UTC | |
by Anonymous Monk on Sep 29, 2009 at 23:04 UTC | |
by ikegami (Patriarch) on Sep 29, 2009 at 23:42 UTC | |
by perlkamal (Initiate) on Oct 18, 2009 at 23:55 UTC | |
by ikegami (Patriarch) on Oct 20, 2009 at 01:23 UTC | |
|
Re: convert a string(which contains the contents of a file) into UTF-8 encoding
by Anonymous Monk on Sep 26, 2009 at 00:34 UTC |