Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: The Queensrˇche Situation

by aitap (Curate)
on Oct 19, 2014 at 20:01 UTC ( #1104341=note: print w/replies, xml ) Need Help??


in reply to Re^2: The Queensrˇche Situation
in thread The Queensrˇche Situation

When you work with Unicode, you should get greater character codes (>=255), not byte sequences, because Perl encapsulates encodings for you. For example,

use utf8;
binmode STDOUT, ":utf8";
my $string = "Queensrˇche ы";
printf "%x\t%s\n", ord($_), $_ for split "", $string;
__END__
51      Q
75      u
65      e
65      e
6e      n
73      s
72      r
ff      ˇ
63      c
68      h
65      e
20       
44b     ы

If you need to work with utf-8 bytes, encode them back:

use utf8;
use Encode 'encode';
binmode STDOUT, ":utf8";
my $string = "Queensrˇche ы";
printf "%x\t%s\n", ord($_), $_ for split "", encode utf8 => $string;
__END__
51      Q
75      u
65      e
65      e
6e      n
73      s
72      r
c3      √
bf      Ņ
63      c
68      h
65      e
20       
d1      —
8b
But there would be no point in using utf8 and Encode in this case.

Replies are listed 'Best First'.
Re^4: The Queensrˇche Situation
by Rodster001 (Pilgrim) on Oct 19, 2014 at 21:00 UTC
    Ok, this is all falling into place for me now. Thank you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1104341]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2018-05-26 05:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?