#!/usr/local/bin/perl use 5.016; use utf8; use strict; use warnings; binmode(STDIN, ':encoding(utf-8)'); binmode(STDOUT, ':encoding(utf-8)'); binmode(STDERR, ':encoding(utf-8)'); my $string = qq[a Å]; my $fh = IO::File->new(); $fh->open(\$string, '<:encoding(UTF-8)'); say $fh->getc(); # a say $fh->getc(); # SPACE say $fh->getc(); # Å LATIN CAPITAL LETTER A WITH RING ABOVE (U+00C5) $fh->ungetc(ord("Å")); say $fh->getc(); # should be A RING again.