Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-05-2007, 08:51 AM
|
#1
|
Member
Registered: Dec 2005
Distribution: RHEL3, FC3
Posts: 383
Rep:
|
display in hex + perl + non ASCII characters
Hi All,
How to display the hex value of non-ASCII characters.
Below code doesnt work!!
Code:
#! /opt/third-party/bin/perl
$var='é';
print ord($var);
$da = sprintf("%lx", $var);
print "\n" . $da . "\n";
exit 0
Thanks!
|
|
|
02-05-2007, 11:49 AM
|
#2
|
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
|
Hard to know for sure what you were expecting, but does this look more like what you want?
Code:
#! /opt/third-party/bin/perl
$var='é';
print ord($var);
$da = sprintf("%lx", ord($var));
print "\n" . $da . "\n";
exit 0
|
|
|
02-05-2007, 10:52 PM
|
#3
|
Member
Registered: Dec 2005
Distribution: RHEL3, FC3
Posts: 383
Original Poster
Rep:
|
With the code I had posted I wont be able to retrieve both the bytes of utf8 encoded character.
Only the first byte of the é would be returned.
I need a methodology to return both the bytes.
é - Since its range is greater than 0x7F it would be encoded in 2 bytes.
Hope I had made my requirement clear
|
|
|
02-06-2007, 05:08 PM
|
#4
|
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
|
Hmmm. I now understand your question, and even after a bit of googling, I regret that I don't have any good answer. I am sorry to have bumped you off the 'zero-reply' list. Perhaps you should start a new thread (which I will leave unsullied), and include some of the language from pages such as http://www.justatheory.com/computers...f8_trials.html
or http://perl.net.au/wiki/Unicode in your subject line.
--- rod.
|
|
|
02-06-2007, 05:48 PM
|
#5
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,426
|
These would be the guys to ask: http://www.perlmonks.org/
|
|
|
All times are GMT -5. The time now is 03:53 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|