Umlauts revisited: Now they prevent program from running
Michael Hudson
mwh21 at cam.ac.uk
Fri Jan 26 08:54:34 EST 2001
"Franz GEIGER" <fgeiger at datec.at> writes:
> I pull data out of an Excel sheet using DAO. There are field values
> containing text strings. Everything works fine until a text reads e.g.
> "Stück".
>
> After stopping before the exception
>
> "UnicodeError: ASCII encoding error: ordinal not in range(128)"
>
> occurs I display the field in the interactive window of PythonWin
> (ActiveState 2.0 on NT4) by simply typing "fld.Value".
>
> It displays u'St\374ck'.
>
> Conversion into a Python string by applying print or str() yields:
>
> "Traceback (innermost last):
> File "<interactive input>", line 1, in ?
> UnicodeError: ASCII encoding error: ordinal not in range(128)"
>
> Any idea how to overcome this?
fld.Value.encode('cp1252') maybe?
--
41. Some programming languages manage to absorb change, but
withstand progress.
-- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html
More information about the Python-list
mailing list