School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,099 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,025 people online right now. Registration is fast and FREE... Join Now!




How to convert the contents into utf-8 encoding

 

How to convert the contents into utf-8 encoding

kamalakar.rao

21 Sep, 2009 - 01:08 AM
Post #1

New D.I.C Head
*

Joined: 21 Sep, 2009
Posts: 1

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.
CODE

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;
}


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 12:09PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month