fork download
  1. #!/usr/bin/perl
  2.  
  3. use v5.10;
  4.  
  5. use open ':std', ':encoding(UTF-8)';
  6. # or binmode STDOUT, ':utf8';
  7.  
  8. use utf8;
  9. use Encode qw(encode);
  10.  
  11. my $text = 'Café';
  12. my @utf8 = unpack 'C*', Encode::encode 'UTF-8', $text;
  13.  
  14. say 'text: ', $text;
  15. say 'dec: ', join ' ', map { sprintf '%3d', $_ } @utf8;
  16. say 'hex: ', join ' ', map { sprintf '%3x', $_ } @utf8;
  17.  
  18.  
Success #stdin #stdout 0.03s 7620KB
stdin
Standard input is empty
stdout
text: Café
dec:   67  97 102 195 169
hex:   43  61  66  c3  a9