Hello,

Anyone out there actually play with Unicode::Map8,
Unicode::String or Unicode::Map?

I don't seem to be make my code working. I am trying
to convert from a utf8 => utf16. Reading from the 
document seems to imply one of the above module
should be able to help me. But, I don't understand
how to use these modules. (I know this is embarrassing, 
this mean I cannot understand what the doc at all).

This is what I did:
-------------- BEGIN -------------
#!/usr/bin/perl -w

use Unicode::Map8;
use Unicode::String;

MAIN:
{
        my $m = Unicode::String->new;
        while ( <> ){
                
                my $line = $_;

                chomp($line);

                ## Is the below tow line make sense??
                $m->utf8($line);
                print $m->utf16, "\n";

        }
}

sub Build_HexString
{
        my $raw = shift;

        my $len = length($raw);
        my $i = 0;
        my $process_code = "";

        while( $i < $len ){

                my $c = substr $raw, $i, 1;
                
                my $hex_num = sprintf("%.2x", ord($c) );

                $process_code .= $hex_num;

                $i++;
        }
        
        return $process_code;
}

------------- END -------------

Basically, I want to convert utf-8 to utf-16 first, 
then display the result in Hex string. 

But, I get a lot of warnning mesasge, and the Hex
string is not what I expected. 

Anyone can explain I mistake I did...

Thanks,
Sei Heng


-- 
Cybersource Pte Ltd
745 Toa Payoh Lorong 5 #03-02
HBM Building Singapore 319455
Tel: (65) 3580575

>> I rather be free in Hell then a slave in Heaven <<

Reply via email to