Click to See Complete Forum and Search --> : how can I convert text files in UTF-16 using Unicode::Map ?


ccc
07-02-2004, 03:48 PM
hi

I need a perl code to convert text file
in UTF-16 using perl module Unicode::Map

http://search.cpan.org/~mschwartz/Unicode-Map-0.112/Map.pm

if someone can post a code, I'll be happy.

kind regards
ccc

CyCo
07-02-2004, 04:32 PM
In the module itself, you will find this sample usage about 3/4 down the page.

use Unicode::Map();

I<$Map> = new Unicode::Map("ISO-8859-1");

I<$utf16> = I<$Map> -> to_unicode ("Hello world!");
=> $utf16 == "\0H\0e\0l\0l\0o\0 \0w\0o\0r\0l\0d\0!"

I<$locale> = I<$Map> -> from_unicode (I<$utf16>);
=> $locale == "Hello world!"

...more details are listed below what I posted above in the module. Hope this helps.