in reply to How to set the UTF8 flag?

It sounds like maybe it's being double-encoded.

The only reliable way I know of is to keep track of what is in utf8 and what is in bytes, and be sure to encode and decode while passing things into / out of the code you wrote. There is the utf8::all module that will usually do what you mean, if you understand where it can go wrong. I think perlunicook is the best practical guide, but it can be hard to find as the other docs (perluniintro, etc.) don't tell you about this one.

🐪