Re: Writing UTF-8 file under Windows
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Fri, 05 Jan 2007 14:49:50 +0000
t_lawetta@xxxxxxxxx writes:
Happy New Year,
Whatever I try to write a UTF-8 file, I always end up with UTF-16LE
with the "FF FE" BOM at the beginning and 2 bytes per character.
I am reading strings from an external resource and try to write to
files.
my $string_with_special_chars = "Château Müller\nGarçon";
open F, ">:utf8", "test.txt";
print F $string_with_special_chars;
close F;
Tried it both on Linux (Perl 5.8.6) and Windows (Perl 5.8.7).
Just a data point. I can't reproduce your problem using Perl 5.8.7 on
Linux, although I have to either:
(a) tell Perl the source is UTF-8 with "use utf8;", or
(b) re-write the string using the encoding my Perl expects.
You can, of course, just use Unicode code points in strings:
"Ch\x{E2}teau..." and then you don't need to worry...
--
Ben.
.
- Follow-Ups:
- Re: Writing UTF-8 file under Windows
- From: Ian Wilson
- Re: Writing UTF-8 file under Windows
- References:
- Writing UTF-8 file under Windows
- From: t_lawetta
- Writing UTF-8 file under Windows
- Prev by Date: is Perl used in the Java middle-tier
- Next by Date: Re: Writing UTF-8 file under Windows
- Previous by thread: Writing UTF-8 file under Windows
- Next by thread: Re: Writing UTF-8 file under Windows
- Index(es):
Relevant Pages
|