You didn't show any relevant input data, but from your description, I have to wonder whether you tried the following and whether it worked:
my $answer = decode('UTF-8', $answer);
You decode external input when reading, and you encode strings before writing them as output.
In reply to Re: UTF-8 and Unicode the hard way
by Corion
in thread UTF-8 and Unicode the hard way
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |