in reply to How to write a utf-8 file

Your code is correct. Either the input file isn't UTF-8, or your viewer isn't treating the output as UTF-8.

Replies are listed 'Best First'.
Re^2: How to write a utf-8 file
by moritz (Cardinal) on Apr 13, 2011 at 06:36 UTC
    Your code is correct.

    Mostly. Since it adds literals to the string, it should also use utf8;, to avoid mixing of decoded and undecoded strings.

      He should add use utf8; if and only if his source code is UTF-8.
      He should omit use utf8; if and only if his source code is iso-8859-1.

      There's absolutely no indication as to which is correct here, so I don't see how you can suggest one over the other.