http://www.perlmonks.org?node_id=1011836


in reply to IO::Handle Unicode and ungetc()

You can work around this by adding a call to binmode just after the open,

$fh->open(\$string, '<:encoding(UTF-8)'); binmode $fh;

However, that only works if you do NOT use either of the ":utf8" or ":encoding(UTF-8)" options on binmode. I'm not that familiar with perl Unicode, but this seems vaguely bug-ish to me offhand.

Update: tested on perl v5.14.3 built for x86_64-linux-thread-multi