Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > unicode <-> hex

Reply
Thread Tools

unicode <-> hex

 
 
nazrat
Guest
Posts: n/a
 
      02-18-2008
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.
 
Reply With Quote
 
 
 
 
Joost Diepenmaat
Guest
Posts: n/a
 
      02-18-2008
nazrat <(E-Mail Removed)> 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/
 
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
hex string to hex value tim Python 8 11-23-2005 06:27 PM
[Fwd: Re: hex string to hex value] tim Python 2 11-23-2005 07:18 AM
Hex Color Codes - Hex 6 <=> Hex 3 lucanos@gmail.com HTML 10 08-18-2005 11:21 PM
hex value in string back to real hex value jack Python 4 09-08-2004 07:11 AM
hex(-5) => Futurewarning: ugh, can't we have a better hex than '-'[:n<0]+hex(abs(n)) ?? Bengt Richter Python 6 08-19-2003 07:33 AM



Advertisments