Re: writing \feff at the begining of a file

2010-08-15 Thread Peter Billam
On 2010-08-14, Martin v. Loewis wrote: >> Is there a standard way to autodetect the encoding of a text file? > Use the chardet module: > http://chardet.feedparser.org/ Very timely: the python-chardet package just seems to have appeared on debian squeeze :-) After my latest "aptitude safe-upgrad

Re: writing \feff at the begining of a file

2010-08-14 Thread Martin v. Loewis
> Is there a standard way to autodetect the encoding of a text file? Use the chardet module: http://chardet.feedparser.org/ Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: writing \feff at the begining of a file

2010-08-14 Thread Thomas Jollans
On Saturday 14 August 2010, it occurred to Steven D'Aprano to exclaim: > On Fri, 13 Aug 2010 18:25:46 -0400, Terry Reedy wrote: > > A short background to MRAB's answer which I will try to get right. > > > > The byte-order-mark was invented for UTF-16 encodings so the reader > > could determine whe

Re: writing \feff at the begining of a file

2010-08-13 Thread Steven D'Aprano
On Fri, 13 Aug 2010 18:25:46 -0400, Terry Reedy wrote: > A short background to MRAB's answer which I will try to get right. > > The byte-order-mark was invented for UTF-16 encodings so the reader > could determine whether the pairs of bytes are in little or big endiean > order, depending on wheth

Re: writing \feff at the begining of a file

2010-08-13 Thread Terry Reedy
A short background to MRAB's answer which I will try to get right. The byte-order-mark was invented for UTF-16 encodings so the reader could determine whether the pairs of bytes are in little or big endiean order, depending on whether the first two bute are fe and ff or ff and fe (or maybe vic

Re: writing \feff at the begining of a file

2010-08-13 Thread Nobody
On Fri, 13 Aug 2010 11:45:28 +0200, Jean-Michel Pichavant wrote: > I'm trying to update the content of a $Microsoft$ VC2005 project files > using a python application. > Since those files are XML data, I assumed I could easily do that. > > My problem is that VC somehow thinks that the file is co

Re: writing \feff at the begining of a file

2010-08-13 Thread MRAB
Jean-Michel Pichavant wrote: Hello python world, I'm trying to update the content of a $Microsoft$ VC2005 project files using a python application. Since those files are XML data, I assumed I could easily do that. My problem is that VC somehow thinks that the file is corrupted and update the

Re: writing \feff at the begining of a file

2010-08-13 Thread Ulrich Eckhardt
Jean-Michel Pichavant wrote: > My problem is however simplier : how do I add such character [a BOM] > at the begining of the file ? > I tried > > f = open('paf', w) > f.write(u'\ufeff') > > UnicodeEncodeError: 'ascii' codec can't encode character u'\ufeff' in > position 0: ordinal not in range(12

Re: writing \feff at the begining of a file

2010-08-13 Thread Tim Golden
On 13/08/2010 10:45, Jean-Michel Pichavant wrote: My problem is however simplier : how do I add such character at the begining of the file ? I tried f = open('paf', w) f = open ("pag", "wb") f.write ("\xfe\xff") TJG -- http://mail.python.org/mailman/listinfo/python-list

writing \feff at the begining of a file

2010-08-13 Thread Jean-Michel Pichavant
Hello python world, I'm trying to update the content of a $Microsoft$ VC2005 project files using a python application. Since those files are XML data, I assumed I could easily do that. My problem is that VC somehow thinks that the file is corrupted and update the file like the following: -