#!/usr/bin/perl

# Idiom #304 Encode string into UTF-8 bytes

use v5.10;

use open ':std', ':encoding(UTF-8)';
# or binmode STDOUT, ':utf8';

use utf8;
my $text = 'Café';
my $utf8 = $text;

utf8::encode($utf8);

my @utf8 = unpack('C*', $utf8);

say 'text: ', $text;
say 'dec:  ', join ' ', map { sprintf '%3d', $_ } @utf8;   
say 'hex:  ', join ' ', map { sprintf '%3x', $_ } @utf8;   
