"The Unicode Standard neither requires nor recommends the use of the BOM
for UTF-8, but does allow the character to be at the start of a file."
I guess the answer is that BOM doesn't do anything for you in UTF-8,
there's no byte-reversed version of the encoding as there is in say UTF-16.
That being said its acceptable to have a BOM, and I'm assuming you have
some software somewhere that requires one.
2 options. Add it on with some shell one-liner afterwards (I believe you
can for instance use 'echo' on most unix boxes to output a few hex
characters and just prepend that to your output after the fact). Beyond
that the example you give probably should work, but maybe your
binmode()/write() should come BEFORE you set up XML::Writer? I'm also not
really sure the ':utf8' is a good idea there, you should probably not be
telling it there's an encoding at all, let perl just write binary bytes to
the file. I'm sure I'd have to experiment a bit to get it right, but you
should be on the right track there. I just don't have time to work through
it right now, sorry.
*“Men occasionally stumble over the truth, but most of them pick themselves
up and hurry off as if nothing had happened.” -*Winston Churchill
On Wed, Jun 3, 2015 at 3:16 AM, Nagy Tamas (TVI-GmbH) <
tama...@tvi-gmbh.de> wrote:
> Hi,>>>> Ok, but how to write the „EF BB BF“ BOM code to the beginning?>> With XML::Writer the print OUTPUT chr(65279) does not do anything.>>>> my $output;>> my $writer;>>>> $output = IO::File->new(">default.xml");>>>> $writer = XML::Writer->new(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT> => " ", ENCODING => "utf-8", NEWLINES => 0 );>>>> binmode(OUTPUT, ":utf8");>> print OUTPUT chr(65279); #BOM>>>> Tamas Nagy>>>>>>>> *Von:* thar...@gmail.com [mailto:thar...@gmail.com] *Im Auftrag von *Tod> Harter> *Gesendet:* Dienstag, 2. Juni 2015 20:02> *An:* Nagy Tamas (TVI-GmbH)> *Cc:* perl...@listserv.ActiveState.com> *Betreff:* Re: How to create an xml file with XMLWriter that has 0A> newlines in strings>>>> UTF-8 and the containing of OD 0A (CRLF) are two separate issues, as these> characters exist as code points in UTF-8 (which is a superset of> US-ASCII/ISO-8860). So, handling the existence of CRLF is really your> business, you can pass ENCODING => 'utf-8', NEWLINES => 0 to> XML::Writer->new() to suppress any 'gratis' newlines, and tell the module> you want output to be utf-8 encoded. Beyond that the content is totally up> to you. I'd advise completely staying away from things like Notepad, it has> very little notion of how things are encoded or what sort of characters are> used, its really a terrible little program. If you STILL need to get rid of> some characters after you output the data from perl, then perhaps a 'one> liner' that simply strips away the offending characters would be the best> idea. Alternately if you insist on using a text editor use something like> TextPad++ that allows you to control line endings and encoding properly.>>> *“Men occasionally stumble over the truth, but most of them pick> themselves up and hurry off as if nothing had happened.” -*Winston> Churchill>>>> On Tue, Jun 2, 2015 at 9:14 AM, Nagy Tamas (TVI-GmbH) <> tama...@tvi-gmbh.de> wrote:>> Hi,>>>> I have to create a special binary format that uses XML.>>>> I create an XML file with XMLWriter. After that I use Notepad++ to convert> it to UTF-8 file.>> The problem is, that also 0D 0A is written into the strings by Notepad++.>>>> How to delete the 0D-s from the strings after conversion? Many hex editors> support>> only overwriting. Which hex editor can delete it?>>>> Or how to create UTF-8 XML files with XMLWriter so that strings never> contain 0D 0A,>> just 0A.>>>> It seems to be impossible with perl XMLWriter.>>>> Visual Studio has a special XML format when a plugin is used. In this XML> format>> 0D 0A is everywhere in the XML except the strings, where there is only 0A.>>>> How is it possible to generate this file?>>>> Tamas Nagy>>>>> _______________________________________________> Perl-XML mailing list> Perl...@listserv.ActiveState.com> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs>>>
_______________________________________________
Perl-XML mailing list
Perl...@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs