This turned out to be a false alarm. Perl and my script were doing the right thing, and there was a bug in the text editor that was corrupting some UTF-8 characters. I notified them of the problem and they sent out a patched version that corrects the problem.