Handling text lines from files with some (few) starnge chars

Paulo da Silva psdasilva.nospam at netcabonospam.pt
Sat Jun 5 21:24:18 EDT 2010


Em 06-06-2010 00:41, Chris Rebert escreveu:
> On Sat, Jun 5, 2010 at 4:03 PM, Paulo da Silva
> <psdasilva.nospam at netcabonospam.pt> wrote:
...

> 
> Specify the encoding of the text when opening the file using the
> `encoding` parameter. For Windows-1252 for example:
> 
> your_file = open("path/to/file.ext", 'r', encoding='cp1252')
> 

OK! This fixes my current problem. I used encoding="iso-8859-15". This
is how my text files are encoded.
But what about a more general case where the encoding of the text file
is unknown? Is there anything like "autodetect"?



More information about the Python-list mailing list