'ascii' codec can't encode character u'\xf3'

Ben Last ben at benlast.com
Tue Aug 17 15:23:38 CEST 2004

> if i use
> #! /usr/bin/env python
> # -*- coding: UTF-8 -*-
> at the begginnig of my every script, the example above still has to
> be converted -- because of the iso-8859-1 you use in "Löwis"?
Be aware that if you declare the encoding as UTF-8, you should really make
sure that you're using an editor that understands UTF-8; not all the
characters you might type freely (or copy and paste) are the same in UTF8
and Latin-1.  For example, if you inadvertently paste an ellipsis (...),
which is \x85 in Western-Europe Windows into such a file, then you may get
errors, since the ellipsis in Unicode is a different code altogether.

The first "page" of UTF-8 maps exactly to ISO-Latin-1 (ISO-8859-1), but
since you're using a Czech locale, I'd expect you to be using Latin-2, and
for your editors to enter characters as Latin-2.


More information about the Python-list mailing list