Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > convert gb18030 to utf16

Reply
Thread Tools

convert gb18030 to utf16

 
 
Xah Lee
Guest
Posts: n/a
 
      03-07-2005
i have a bunch of files encoded in GB18030. Is there a way to convert
them to utf16?


Xah
(E-Mail Removed)
http://xahlee.org/PageTwo_dir/ more.html

 
Reply With Quote
 
 
 
 
Xah Lee
Guest
Posts: n/a
 
      03-07-2005
Can you tell me when did this module became part of Perl? (what
version)

(i haven't been active in Perl since 2004)

Thanks.

Xah
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://xahlee.org/PageTwo_dir/more.html


William Ahern wrote:
> Xah Lee <(E-Mail Removed)> wrote:
> > i have a bunch of files encoded in GB18030. Is there a way to

convert
> > them to utf16?

>
> The process would go roughly like so
>
> use Encode qw/encode decode/;
>
> open FILE, '</path/to/gb18030/file' or die "open: $!";
>
> $\ = undef;
>
> my $utf8 = decode('gb18030',<FILE>);
> my $ucs2 = encode('UCS-2BE', $utf;
>
> If this is going to be a regular process, you should wrap that in an

eval{}
> because the Encode routines like to call die, regardless of whether

you pass
> in options like Encode::FB_DEFAULT or Encode::FB_QUIET.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse doesn't support GB18030 file encoding? Cal Java 0 06-25-2007 09:24 AM
Regarding UTF16 news.fe.internet.bosch.com C Programming 5 02-12-2006 10:01 AM
UTF16, BOM, and Windows Line endings Fuzzyman Python 4 02-07-2006 09:23 AM
UTF16 codec doesn't round-trip? John Perks and Sarah Mount Python 1 05-28-2005 10:33 PM
convert gb18030 to utf16 Xah Lee Python 2 03-07-2005 01:35 PM



Advertisments