Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How to print the actual bytes of UTF-8 characters ?

by pajout (Curate)
on Feb 07, 2014 at 13:09 UTC ( [id://1073875] : note . print w/replies, xml ) Need Help??


in reply to How to print the actual bytes of UTF-8 characters ?

I think you need something like this:
#!/usr/bin/perl use utf8; my $str = ' '; print $str."\n"; foreach my $ch (split('', $str)) { print ord($ch)."\n"; } use bytes; print "bytes\n"; foreach my $ch (split('', $str)) { printf("%x %b\n", ord($ch), ord($ch)); }