in reply to Re: use encoding affects pack()
in thread use encoding affects pack()

That did it! Thanks a lot. It's obvious, now that I think about it, but that's usually the case isn't it.

My full problem got slightly more complicated by the fact that I also had to output some actual UTF-8 at the same time, but using encode("utf8", $string) gave me what I needed.