unicode <-> hex

Discussion in 'Perl Misc' started by nazrat, Feb 18, 2008.

  1. nazrat

    nazrat Guest

    i'd like to know if there's a way to get back the original hex values
    of a unicode character.
    ex:
    my $u = "\x{20A3}";
    my $h = pack(....., $u) ? so that $h is now a string '20A3'. thanks.
    nazrat, Feb 18, 2008
    #1
    1. Advertising

  2. nazrat <> writes:

    > i'd like to know if there's a way to get back the original hex values
    > of a unicode character.
    > ex:
    > my $u = "\x{20A3}";
    > my $h = pack(....., $u) ? so that $h is now a string '20A3'. thanks.


    my $h = sprintf("%X",ord($u));

    There's probably some way to do this using (un)pack, but I doubt it's much
    more efficient if you're going at it char-by-char.

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
    Joost Diepenmaat, Feb 18, 2008
    #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. Replies:
    10
    Views:
    6,139
    Neredbojias
    Aug 19, 2005
  2. Bengt Richter
    Replies:
    6
    Views:
    449
    Juha Autero
    Aug 19, 2003
  3. jack
    Replies:
    4
    Views:
    575
  4. tim

    hex string to hex value

    tim, Nov 22, 2005, in forum: Python
    Replies:
    8
    Views:
    18,797
  5. tim
    Replies:
    2
    Views:
    1,540
    Dennis Lee Bieber
    Nov 23, 2005
Loading...

Share This Page