Re: How to create an xml file with XMLWriter that has 0A newlines in strings
Tod Harter <[email protected]> Tue, 2 Jun 2015 13:01:40 -0500
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <CAC0h5Yyvumk0cxHJErKuH85GVFdhZvfzgy-uh1+KJL+z+khfiw@mail.gmail.com> |
--===============0887739125== Content-Type: multipart/alternative; boundary=047d7b6d7d94042b3705178cbc69 --047d7b6d7d94042b3705178cbc69 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 =3D> 'utf-8', NEWLINES =3D> 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. *=E2=80=9CMen occasionally stumble over the truth, but most of them pick th= emselves up and hurry off as if nothing had happened.=E2=80=9D -*Winston Churchill On Tue, Jun 2, 2015 at 9:14 AM, Nagy Tamas (TVI-GmbH) < [email protected]> 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 conver= t > 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 editor= s > 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 > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > --047d7b6d7d94042b3705178cbc69 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">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 super= set of US-ASCII/ISO-8860). So, handling the existence of CRLF is really you= r business, you can pass ENCODING =3D> 'utf-8', NEWLINES =3D>= 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 conten= t 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 s= ort of characters are used, its really a terrible little program. If you ST= ILL 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 c= haracters would be the best idea. Alternately if you insist on using a text= editor use something like TextPad++ that allows you to control line ending= s and encoding properly. <br></div><div class=3D"gmail_extra"><br clear=3D"= all"><div><div class=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"= ltr"><em>=E2=80=9CMen occasionally stumble over the truth, but most of them= pick themselves up and hurry off as if nothing had happened.=E2=80=9D -</e= m>Winston Churchill</div></div></div></div></div> <br><div class=3D"gmail_quote">On Tue, Jun 2, 2015 at 9:14 AM, Nagy Tamas (= TVI-GmbH) <span dir=3D"ltr"><<a href=3D"mailto:[email protected]" t= arget=3D"_blank">[email protected]</a>></span> wrote:<br><blockquot= e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol= id;padding-left:1ex"> <div link=3D"#0563C1" vlink=3D"#954F72" lang=3D"DE"> <div> <p class=3D"MsoNormal">Hi,<u></u><u></u></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal">I have to create a special binary format that uses X= ML.<u></u><u></u></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal">I create an XML file with XMLWriter. After that I us= e Notepad++ to convert it to UTF-8 file.<u></u><u></u></p> <p class=3D"MsoNormal">The problem is, that also 0D 0A is written into the = strings by Notepad++.<u></u><u></u></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal">How to delete the 0D-s from the strings after conver= sion? Many hex editors support<u></u><u></u></p> <p class=3D"MsoNormal">only overwriting. Which hex editor can delete it?<u>= </u><u></u></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal">Or how to create UTF-8 XML files with XMLWriter so t= hat strings never contain 0D 0A,<u></u><u></u></p> <p class=3D"MsoNormal">just 0A.<u></u><u></u></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal">It seems to be impossible with perl XMLWriter.<u></u= ><u></u></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal">Visual Studio has a special XML format when a plugin= is used. In this XML format<u></u><u></u></p> <p class=3D"MsoNormal">0D 0A is everywhere in the XML except the strings, w= here there is only 0A.<u></u><u></u></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal">How is it possible to generate this file?<span class= =3D"HOEnZb"><font color=3D"#888888"><u></u><u></u></font></span></p><span c= lass=3D"HOEnZb"><font color=3D"#888888"> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal"><span style=3D"font-size:8.0pt;font-family:"Ver= dana",sans-serif;color:#1f497d">Tamas Nagy<u></u><u></u></span></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> </font></span></div> </div> <br>_______________________________________________<br> Perl-XML mailing list<br> <a href=3D"mailto:[email protected]">[email protected]= veState.com</a><br> To unsubscribe: <a href=3D"http://listserv.ActiveState.com/mailman/mysubs" = target=3D"_blank">http://listserv.ActiveState.com/mailman/mysubs</a><br> <br></blockquote></div><br></div> --047d7b6d7d94042b3705178cbc69-- --===============0887739125== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs --===============0887739125==--