On Sat, Jan 23, 2021, at 05:06, Inada Naoki wrote:
> On Sat, Jan 23, 2021 at 2:43 PM Random832 <random...@fastmail.com> wrote:
> >
> > On Fri, Jan 22, 2021, at 20:34, Inada Naoki wrote:
> > > * Default encoding is "utf-8".
> >
> > it might be worthwhile to be a little more sophisticated than this.
> >
> > Notepad itself uses character set detection [it might not be reasonable to 
> > do this on the whole file as notepad does, but maybe the first 512 bytes, 
> > or the result of read1(512)?] when opening a file of unknown encoding, and 
> > msvcrt's "ccs=UTF-8" option to fopen will at least detect at the presence 
> > of UTF-8 and UTF-16 BOMs [and treat the file as UTF-16 in the latter case].
> 
> I meant Notepad (and VS code) use UTF-8 without BOM when creating new text 
> file.
> Students learning Python can not read it with `open()`.

Right, I was simply suggesting it might be worthwhile to target "be able to 
open all files that notepad can open" as the goal rather than simply defaulting 
to UTF8-no-BOM only, which requires a little more sophistication than just a 
default encoding.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/VJ67ZCY7HG6JTWM4K2JDZDQAJIXEMF4T/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to