LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   I need perlscript to convert text file in UTF-16 (http://www.linuxquestions.org/questions/programming-9/i-need-perlscript-to-convert-text-file-in-utf-16-a-200409/)

cccc 07-02-2004 04:00 PM

I need perlscript to convert text file in UTF-16
 
hi

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

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

greetings
cccc

ToniT 07-02-2004 04:26 PM

Can't you just use
Code:

recode latin1..utf16 yourfile.txt
?

cccc 07-03-2004 08:12 PM

thanks, but howto use this command from perl script ?

ToniT 07-04-2004 05:08 AM

Just as any other external program,
eg.
Code:

#!/usr/bin/perl -w
system("recode latin1..utf16 foo.txt");

To do the equivalent with Unicode::Map library (reads Latin1 from stdin and writes UTF16 to stdout):
Code:

#!/usr/bin/perl -w

use Unicode::Map();
$Map = new Unicode::Map("ISO-8859-1");
print $Map->to_unicode($_) while(<>);



All times are GMT -5. The time now is 09:45 PM.