ensuring valid latin-1
Chris Curvey
ccurvey at gmail.com
Wed Nov 29 16:47:42 EST 2006
Hey all,
I'm trying to write something that will "fail fast" if one of my users
gives me non-latin-1 characters. So I tried this:
>>> testString = "\x80"
>>> foo = unicode(testString, "latin-1")
>>> foo
u'\x80'
I would have thought that that should have raised an error, because
\x80 is not a valid character in latin-1 (according to what I can
find). Is this the expected behavior, or am I missing something?
I'm on Windows, but I have explicitly set the character set to be
latin-1 in sitecustomize.py
>>> import sys
>>> sys.getdefaultencoding()
'latin-1'
More information about the Python-list
mailing list