in reply to dup and add an encoding layer to a file handle?

Try using
":encoding(UTF-8)"