[Zope] UnicodeEncodeError

Laura McCord Laura.McCord at doucet-austin.com
Thu Oct 21 12:00:28 EDT 2004


Turns out the error was caused by putting quotes around a word in the
Title Section of an item.

I removed them and replaced it with single-quotes and it worked
perfectly. 

Thanks for your help,
 Laura

-----Original Message-----
From: Tino Wildenhain [mailto:tino at wildenhain.de] 
Sent: Thursday, October 21, 2004 9:38 AM
To: Laura McCord
Cc: zope at zope.org
Subject: Re: [Zope] UnicodeEncodeError


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