EOL created by .write or .encode
Xah Lee
xah at xahlee.org
Sun Apr 10 03:49:32 EDT 2005
can any GNU person or emacs coder answer this?
specifically: why does what-cursor-position give incorrect answer.
Xah
xah at xahlee.org
∑ http://xahlee.org/PageTwo_dir/more.html ☄
Xah Lee wrote:
> I found the problem now. (after some one hour debug time) Python
> didn't have problem. Emacs does.
>
> If you open a file in emacs, it will open fine regardless whether the
> EOL is ascii 10 or 13. (unix or mac) This is a nice feature. However,
> the what-cursor-position which is used to show cursor position and
the
> char's ascii code, says the EOL is ascii 10 when it is in fact ascii
> 13. Fuck the irresponsible fuckhead who is responsible for this.
>
> http://xahlee.org/UnixResource_dir/writ/responsible_license.html
>
> Xah
> xah at xahlee.org
> ∑ http://xahlee.org/
>
>
>
> Xah Lee wrote:
> > Why is that some of my files written out by
> > outF.write(outtext.encode('utf-8'))
> > has ascii 10 as EOL, while others has ascii 13 as EOL?
> > both of these files's EOL are originally all ascii 10.
> >
> > If i remove the EOL after the tt below in the place string, then
this
> > doesn't happen.
> >
> > findreplace = [
> > (ur'</body>',
> > ur'''tt
> > </body>'''),
> > ]
> >
> > ...
> >
> > inF = open(filePath,'rb')
> > s=unicode(inF.read(),'utf-8')
> > inF.close()
> >
> > for couple in findreplace:
> > outtext=s.replace(couple[0],couple[1])
> > s=outtext
> > outF = open(tempName,'wb')
> > outF.write(outtext.encode('utf-8'))
> > outF.close()
> >
> > thanks.
> >
> > Xah
> > xah at xahlee.org
> > ∑ http://xahlee.org/PageTwo_dir/more.html ☄
More information about the Python-list
mailing list