convert gb18030 to utf16

Discussion in 'Perl Misc' started by Xah Lee, Mar 7, 2005.

  1. Xah Lee

    Xah Lee Guest

    Xah Lee, Mar 7, 2005
    #1
    1. Advertising

  2. Xah Lee

    Xah Lee Guest

    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://xahlee.org/PageTwo_dir/more.html


    William Ahern wrote:
    > Xah Lee <> 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', $utf8);
    >
    > 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.
    Xah Lee, Mar 7, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xah Lee

    convert gb18030 to utf16

    Xah Lee, Mar 6, 2005, in forum: Python
    Replies:
    2
    Views:
    1,523
    Xah Lee
    Mar 7, 2005
  2. John Perks and Sarah Mount

    UTF16 codec doesn't round-trip?

    John Perks and Sarah Mount, May 28, 2005, in forum: Python
    Replies:
    1
    Views:
    439
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    May 28, 2005
  3. Fuzzyman
    Replies:
    4
    Views:
    543
    Fuzzyman
    Feb 7, 2006
  4. news.fe.internet.bosch.com

    Regarding UTF16

    news.fe.internet.bosch.com, Feb 2, 2006, in forum: C Programming
    Replies:
    5
    Views:
    342
    those who know me have no need of my name
    Feb 12, 2006
  5. Cal
    Replies:
    0
    Views:
    834
Loading...

Share This Page