How do I get around this? Error Type: UnicodeError Error Value: ASCII decoding error: ordinal not in range(128) There are non-ascii characters stored in properties of folders and I'm trying to build an xml string to send off to a ParsedXML object for parsing. Do I need to encode with a different encoding? I'm basically doing: XMLstring = XMLstring + new_part_from_folder_property Thanks, -Chris
You might try to set the default characterset encoding of your Python interpreter to "iso-8859-1". Python defaults to ascii (check your site.py file of your Python installation). -aj ----- Original Message ----- From: "Christopher N. Deckard" <chris@globalfoo.net> To: <zope@zope.org> Sent: Tuesday, August 27, 2002 13:45 Subject: [Zope] unicode error
How do I get around this?
Error Type: UnicodeError Error Value: ASCII decoding error: ordinal not in range(128)
There are non-ascii characters stored in properties of folders and I'm trying to build an xml string to send off to a ParsedXML object for parsing. Do I need to encode with a different encoding? I'm basically doing:
XMLstring = XMLstring + new_part_from_folder_property
Thanks, -Chris
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Tuesday 27 Aug 2002 12:44 pm, Andreas Jung wrote:
You might try to set the default characterset encoding of your Python interpreter to "iso-8859-1". Python defaults to ascii (check your site.py file of your Python installation).
Yes, but that may not be supported in future http://mail.python.org/pipermail/i18n-sig/2000-July/000344.html
Error Type: UnicodeError Error Value: ASCII decoding error: ordinal not in range(128)
There are non-ascii characters stored in properties of folders and I'm trying to build an xml string to send off to a ParsedXML object for parsing. Do I need to encode with a different encoding? I'm basically doing:
XMLstring = XMLstring + new_part_from_folder_property
I guess that XMLString is a unicode object, and new_part_from_folder_property is a plain string that contains characters outside the ASCII range. What character encoding have you used for those properties? You need to use code like: XMLstring = XMLstring + unicode(new_part_from_folder_property,'UTF-8') subsitute your real encoding for utf-8 A better solution might be to store new_part_from_folder_property as a unicode object.
On Tue, 27 Aug 2002 13:23:28 +0100, Toby Dickenson <tdickenson@geminidataloggers.com> spoke forth:
On Tuesday 27 Aug 2002 12:44 pm, Andreas Jung wrote:
You might try to set the default characterset encoding of your Python interpreter to "iso-8859-1". Python defaults to ascii (check your site.py file of your Python installation).
Does case sensitivity make a difference? I did "ISO-8859-1", following an email in one of the list archives. Still had the same problem.
Yes, but that may not be supported in future
http://mail.python.org/pipermail/i18n-sig/2000-July/000344.html
Error Type: UnicodeError Error Value: ASCII decoding error: ordinal not in range(128)
There are non-ascii characters stored in properties of folders and I'm trying to build an xml string to send off to a ParsedXML object for parsing. Do I need to encode with a different encoding? I'm basically doing:
XMLstring = XMLstring + new_part_from_folder_property
I guess that XMLString is a unicode object, and new_part_from_folder_property is a plain string that contains characters outside the ASCII range.
Actually, XMLstring is a str, and the new_part_from_folder_property is some weird string. I don't know the encoding type. I'm not I know how to find it either...
What character encoding have you used for those properties? You need to use code like:
XMLstring = XMLstring + unicode(new_part_from_folder_property,'UTF-8')
subsitute your real encoding for utf-8
Real encoding being the encoding type of the string right?
A better solution might be to store new_part_from_folder_property as a unicode object.
I have no control of that. It is a string from a zope property. -Chris
On Tue, 27 Aug 2002 07:31:23 -0500, "Christopher N. Deckard" <chris@globalfoo.net> spoke forth:
On Tue, 27 Aug 2002 13:23:28 +0100, Toby Dickenson <tdickenson@geminidataloggers.com> spoke forth:
On Tuesday 27 Aug 2002 12:44 pm, Andreas Jung wrote:
You might try to set the default characterset encoding of your Python interpreter to "iso-8859-1". Python defaults to ascii (check your site.py file of your Python installation).
Does case sensitivity make a difference? I did "ISO-8859-1", following an email in one of the list archives. Still had the same problem.
Ok, so better testing shows that the update to "encoding" in site.py seems to have fixed the problem. On systems where you can't do that, what would be the "ideal" solution? -Chris
Andreas Jung writes:
You might try to set the default characterset encoding of your Python interpreter to "iso-8859-1". Python defaults to ascii (check your site.py file of your Python installation). "sitecustomize.py" (in "site-python") is better, as it does not move with new Python versions...
Dieter
On 19 Elul 5762, Christopher N. Deckard wrote:
How do I get around this?
Error Type: UnicodeError Error Value: ASCII decoding error: ordinal not in range(128)
There are non-ascii characters stored in properties of folders and I'm trying to build an xml string to send off to a ParsedXML object for parsing. Do I need to encode with a different encoding? I'm basically doing:
XMLstring = XMLstring + new_part_from_folder_property
Would something like this help? XMLstring = XMLstring + new_part_from_folder_property.encode('latin-1','replace') I had to do something like this when messing around with results from the GoogleAPI beta. If something other than "latin-1" is appropriate then replace that. -- Charles Sebold K'tivah V'chatimah Tovah 19th of Elul, 5762 http://www.livingtorah.org/Zope/journal
participants (6)
-
Andreas Jung -
Charles Sebold -
Christopher N. Deckard -
Christopher N. Deckard -
Dieter Maurer -
Toby Dickenson