[Zope] UnicodeEncodeError
Tino Wildenhain
tino at wildenhain.de
Thu Oct 21 10:38:12 EDT 2004
Hi,
On Thu, 2004-10-21 at 16:29, Laura McCord wrote:
> Does anyone know what needs to be done when receiving this error?
>
> UnicodeEncodeError
> 'latin-1' codec can't encode character u'\u201c' in position 69622:
> ordinal not in range(256)
>
> I have been searching online but I have not gotten a solid resolution.
Well, all you need stands out very clear in the error message ;)
the Character u'\u201c' burried somewhere in a string you want
to output, has an ordinal number of 8220. And 8220 is far bigger
then 256 - which is the upper bound for latin-1 alphabet.
Just remove it or read on at:
>>> help(u"".encode)
Help on built-in function encode:
encode(...)
S.encode([encoding[,errors]]) -> string
Return an encoded string version of S. Default encoding is the
current
default string encoding. errors may be given to set a different
error
handling scheme. Default is 'strict' meaning that encoding errors
raise
a UnicodeEncodeError. Other possible values are 'ignore', 'replace'
and
'xmlcharrefreplace' as well as any other name registered with
codecs.register_error that can handle UnicodeEncodeErrors.
you can explicitely use yourstring.encode("iso-8859-1",'ignore')
or some of the other options above.
HTH
Tino
More information about the Zope
mailing list