Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

"Looking" at the characters of a Unicode string.

by olivierp (Hermit)
on Nov 29, 2004 at 19:47 UTC ( #411028=snippet: print w/replies, xml ) Need Help??
Description: Recently, I was stumped by "strange black boxes" appearing in a Win32 application textfield, whose contents are retrieved from a Unicode database field.

I used the following snippet to help me identify what was a "bad" mix sequence of <CR> and <LF> characters.
use Unicode::CharName qw/uname/;
use Unicode::UCD qw/charinfo/;

my $value = <what you are looking at>
my $c;
print "Unicode Charname:\tHexValue:\tCharCode\n";
for (split //, $value) {
  $c = ord($_);
  print uname($c) .":\t" . charinfo($c)->{code} . ":\t$c\n";
Replies are listed 'Best First'.
Re: "Looking" at the characters of a Unicode string.
by gaal (Parson) on Nov 29, 2004 at 19:54 UTC
Re: "Looking" at the characters of a Unicode string.
by zentara (Archbishop) on Nov 30, 2004 at 19:10 UTC
    Nice. I modified my copy to display the letter, and reversed the print string so that the long text of the unicode name didn't muck up the tab columns.
    #!/usr/bin/perl use warnings; use strict; use Unicode::CharName qw/uname/; use Unicode::UCD qw/charinfo/; my $value = shift || "Å være eller å ikke være"; my $c; print "HexValue:\tCharCode\tUnicode Charname:\n"; for (split //, $value) { my $l = $_; $c = ord($_); print charinfo($c)->{code} . ":\t\t$c\t\t"."$l -> ". uname($c) ."\n"; }

    I'm not really a human, but I play one on earth. flash japh
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://411028]
[marioroy]: I imagined Perl as a box of crayons. Then painted MCE and MCE::Shared. Not sure how one can paint playing Cello.
[marioroy]: That will be interesting.
[marioroy]: Maybe I cannot paint sound.
[Discipulus]: oh windows platform burned many brains, even this i know by experience
[karlgoethebier]: Discipulus: but don't try the guitar. It will you sick for the rest of your life...
[karlgoethebier]: ...make..
[Discipulus]: oh for sure mario: listen to the whole color box: Goldberg Variations by glenn gould
[Discipulus]: hi karl, i played (well tried to) play the guitar since many years. it is something not natural for me: with the flute was love at first .. sound

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (12)
As of 2017-03-24 10:02 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (298 votes). Check out past polls.