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.
In reply to Re^2: How to write a utf-8 file
by moritz
in thread How to write a utf-8 file
by srikrishnan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |