Re: How to append BOM at the beginning of a binary
Francesco Nidito <[email protected]> Tue, 9 Jun 2015 16:55:03 +0100
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <CANn_qE7ro0g=pKsxF3K-wJcfan2S+vBoie-mH53B=SjgtJRS_Q@mail.gmail.com> |
--===============0063956263== Content-Type: multipart/alternative; boundary=e89a8ff1ccb44a0871051817c945 --e89a8ff1ccb44a0871051817c945 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable My bad... it should have been "FEFF" instead of "FFEF" (why the h**l did I write that reverse?) ------------------------------ =C2=ABWith sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead.=C2= =BB =E2=80=94 R. Callon (rfc1925) On 9 June 2015 at 15:26, Nagy Tamas (TVI-GmbH) <[email protected]> wrote: > Hi, > > > > I tried: > > perl -CO -ne "BEGIN{print qq{\x{BBBF}}}; print" in.xml > out.xml > > > > but it writes: EB AE BF to the beginning, so there is an AE in it, but wh= y? > > So it prepends to the proper place but not the proper characters. > > > > perl -CO -ne "BEGIN{print qq{\x{EB}}}; print" out.xml > out2.xml > > > > i did not run the last one, because former prepended characters are wrong= . > > > > Tamas Nagy > > > > *Von:* Francesco Nidito [mailto:[email protected]] > *Gesendet:* Dienstag, 9. Juni 2015 09:58 > *An:* Nagy Tamas (TVI-GmbH) > *Cc:* [email protected] > *Betreff:* Re: How to append BOM at the beginning of a binary > > > > Try: perl -CO -ne "BEGIN{print qq{\x{FFEF}}}; print" in.xml > out.xml > > > > ------------------------------ > > =C2=ABWith sufficient thrust, pigs fly just fine. However, this is not > necessarily a good idea. It is hard to be sure where they are going to > land, and it could be dangerous sitting under them as they fly overhead.= =C2=BB > =E2=80=94 R. Callon (rfc1925) > > > > On 9 June 2015 at 08:11, Nagy Tamas (TVI-GmbH) <[email protected]> > wrote: > > Hi, > > All the 3 gives the error in Windows CMD: > > "Can't do inplace edit without backup." > > Tamas Nagy > > > On 6/8/15 10:48 AM, Nagy Tamas (TVI-GmbH) wrote: > > Hi, > > > > perl -p -i -e 'BEGIN { printf "%c%c%c", 0xEF, 0xBB, 0xBF }' > > default.xml perl -p -i -e 'BEGIN { print pack "c3", 0xEF, 0xBB, 0xBF > > }' default.xml > > > > Both give the same error: > > > > Can't find string terminator "'" anywhere before EOF at -e line 1. > > > > Is it because of Windows CMD? How to get it work? > > Yeah, that's probably due to the peculiar command line parsing in > Windows. I happen to be on a Mac, but its shell is the same as the shell > on Linux. > > I don't have a Windows machine to test it on, but I think that it wants > double quotes to enclose the script. Any quotes inside the script either > have to be single quotes (if the string doesn't require variable > interpolation), > > perl -p -i -e "BEGIN { printf '%c%c%c', 0xEF, 0xBB, 0xBF }" default.xml > > or escaped double quotes, > > perl -p -i -e "BEGIN { printf \"%c%c%c\", 0xEF, 0xBB, 0xBF }" default.x= ml > > or use a quoting operator, > > perl -p -i -e "BEGIN { printf qq{%c%c%c}, 0xEF, 0xBB, 0xBF }" default.x= ml > > > That would apply to any Perl one-liner you try to run on Windows. > Most Perl one-liner examples that you are likely to find on the web assum= e > a Unix-like shell. > > I know all that is a digression from your XML problem, but a solution to > that problem might be expressible as a one-liner, also, so it's important > to get past this minor obstacle. > > Why do you think you need to put a BOM on your XML file? > > -- > David Thomas > Sugar Land, Texas > _______________________________________________ > Perl-XML mailing list > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ > Perl-XML mailing list > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > > > _______________________________________________ > Perl-XML mailing list > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > --e89a8ff1ccb44a0871051817c945 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">My bad... it should have been "FEFF" instead of = "FFEF" (why the h**l did I write that reverse?)=C2=A0</div><div c= lass=3D"gmail_extra"><br clear=3D"all"><div><div class=3D"gmail_signature">= <br> <div> <hr> =C2=ABWith sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead.=C2=BB<br> =E2=80=94 R. Callon (rfc1925)</div></div></div> <br><div class=3D"gmail_quote">On 9 June 2015 at 15:26, Nagy Tamas (TVI-Gmb= H) <span dir=3D"ltr"><<a href=3D"mailto:[email protected]" target= =3D"_blank">[email protected]</a>></span> wrote:<br><blockquote cla= ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa= dding-left:1ex"> <div lang=3D"DE" link=3D"blue" vlink=3D"purple"> <div> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca= libri",sans-serif;color:#1f497d">Hi,<u></u><u></u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca= libri",sans-serif;color:#1f497d"><u></u>=C2=A0<u></u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca= libri",sans-serif;color:#1f497d">I tried:<u></u><u></u></span></p> <p class=3D"MsoNormal">perl -CO -ne "BEGIN{print qq{\x{BBBF}}}; print&= quot; in.xml > out.xml<u></u><u></u></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal">but it writes: EB AE BF to the beginning, so there i= s an AE in it, but why?<u></u><u></u></p> <p class=3D"MsoNormal">So it prepends to the proper place but not the prope= r characters.<u></u><u></u></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal">perl -CO -ne "BEGIN{print qq{\x{EB}}}; print&qu= ot; out.xml > out2.xml<u></u><u></u></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal">i did not run the last one, because former prepended= characters are wrong.<u></u><u></u></p> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca= libri",sans-serif;color:#1f497d">Tamas Nagy<u></u><u></u></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca= libri",sans-serif;color:#1f497d"><u></u>=C2=A0<u></u></span></p> <p class=3D"MsoNormal"><b><span style=3D"font-size:11.0pt;font-family:"= ;Calibri",sans-serif">Von:</span></b><span style=3D"font-size:11.0pt;f= ont-family:"Calibri",sans-serif"> Francesco Nidito [mailto:<a hre= f=3D"mailto:[email protected]" target=3D"_blank">francesco.nidito@= gmail.com</a>] <br> <b>Gesendet:</b> Dienstag, 9. Juni 2015 09:58<br> <b>An:</b> Nagy Tamas (TVI-GmbH)<br> <b>Cc:</b> <a href=3D"mailto:[email protected]" target=3D"_= blank">[email protected]</a><br> <b>Betreff:</b> Re: How to append BOM at the beginning of a binary<u></u><u= ></u></span></p><div><div class=3D"h5"> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <div> <p class=3D"MsoNormal">Try: perl -CO -ne "BEGIN{print qq{\x{FFEF}}}; p= rint" in.xml > out.xml<u></u><u></u></p> </div> <div> <p class=3D"MsoNormal"><br clear=3D"all"> <u></u><u></u></p> <div> <div> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <div> <div class=3D"MsoNormal" align=3D"center" style=3D"text-align:center"> <hr size=3D"2" width=3D"100%" align=3D"center"> </div> <p class=3D"MsoNormal">=C2=ABWith sufficient thrust, pigs fly just fine. Ho= wever, this is not necessarily a good idea. It is hard to be sure where the= y are going to land, and it could be dangerous sitting under them as they f= ly overhead.=C2=BB<br> =E2=80=94 R. Callon (rfc1925)<u></u><u></u></p> </div> </div> </div> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> <div> <p class=3D"MsoNormal">On 9 June 2015 at 08:11, Nagy Tamas (TVI-GmbH) <<= a href=3D"mailto:[email protected]" target=3D"_blank">tamas.nagy@tvi-g= mbh.de</a>> wrote:<u></u><u></u></p> <blockquote style=3D"border:none;border-left:solid #cccccc 1.0pt;padding:0c= m 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm"> <p class=3D"MsoNormal">Hi,<br> <br> All the 3 gives the error in Windows CMD:<br> <br> "Can't do inplace edit without backup."<br> <span style=3D"color:#888888"><br> <span>Tamas Nagy</span></span><u></u><u></u></p> <div> <div> <p class=3D"MsoNormal"><br> On 6/8/15 10:48 AM, Nagy Tamas (TVI-GmbH) wrote:<br> > Hi,<br> ><br> > perl -p -i -e 'BEGIN { printf "%c%c%c", 0xEF, 0xBB, 0xBF= }'<br> > default.xml perl -p -i -e 'BEGIN { print pack "c3", 0xEF= , 0xBB, 0xBF<br> > }' default.xml<br> ><br> > Both give the same error:<br> ><br> > Can't find string terminator "'" anywhere before EOF= at -e line 1.<br> ><br> > Is it because of Windows CMD? How to get it work?<br> <br> Yeah, that's probably due to the peculiar command line parsing in Windo= ws.=C2=A0 I happen to be on a Mac, but its shell is the same as the shell o= n Linux.<br> <br> I don't have a Windows machine to test it on, but I think that it wants= double quotes to enclose the script.=C2=A0 Any quotes inside the script ei= ther have to be single quotes (if the string doesn't require variable i= nterpolation),<br> <br> =C2=A0 perl -p -i -e "BEGIN { printf '%c%c%c', 0xEF, 0xBB, 0xB= F }" default.xml<br> <br> or escaped double quotes,<br> <br> =C2=A0 perl -p -i -e "BEGIN { printf \"%c%c%c\", 0xEF, 0xBB,= 0xBF }" default.xml<br> <br> or use a quoting operator,<br> <br> =C2=A0 perl -p -i -e "BEGIN { printf qq{%c%c%c}, 0xEF, 0xBB, 0xBF }&qu= ot; default.xml<br> <br> <br> That would apply to any Perl one-liner you try to run on Windows.<br> Most Perl one-liner examples that you are likely to find on the web assume = a Unix-like shell.<br> <br> I know all that is a digression from your XML problem, but a solution to th= at problem might be expressible as a one-liner, also, so it's important= to get past this minor obstacle.<br> <br> Why do you think you need to put a BOM on your XML file?<br> <br> --<br> David Thomas<br> Sugar Land, Texas<br> _______________________________________________<br> Perl-XML mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">Perl= [email protected]</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> Perl-XML mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">Perl= [email protected]</a><br> To unsubscribe: <a href=3D"http://listserv.ActiveState.com/mailman/mysubs" = target=3D"_blank"> http://listserv.ActiveState.com/mailman/mysubs</a><u></u><u></u></p> </div> </div> </blockquote> </div> <p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p> </div> </div></div></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> --e89a8ff1ccb44a0871051817c945-- --===============0063956263== 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 --===============0063956263==--