Hi, I am using the below method to convert a string(which contains the contents of a file) into UTF-8 encoding. But some of the contents like Copyright symbol, Trademark and syperscript symbol is not converting proplery and these symbols are displayed as Â. Could anyone please help me in solving this problem.
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; }

In reply to convert a string(which contains the contents of a file) into UTF-8 encoding by kamalakar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.