Bryan Murdock wrote:
On 9/25/05, Bryan Murdock <[EMAIL PROTECTED]> wrote:

Also, I still get this error now that I've decoded cp1252 and encoded utf-8:

Traceback (most recent call last):
 File "./lesson_todo", line 159, in ?
   lessonTodo = bp.list.create( lessonsPage[0], todo )
 File "backpack.py", line 462, in create
   return self._parseList(x)[0]
 File "backpack.py", line 444, in _parseList
   rv.append((int(item.getAttribute("id")),
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in
position 4: ordinal not in range(128)

Was encoding to utf-8 a bad idea?


Looking close at this error, the whole rv.append call looks like this:

rv.append((int(item.getAttribute("id")),
                item.getAttribute("completed") == "true",
                str(item.firstChild.data)))

data at this point includes the utf-8 quotation marks, so I'm guessing
the real problem is the str call, right?  I'm getting tired, but is
there a quickie way to fix this I'm not seeing?  I'm not opposed to
modifying the libray to better handle this unicode stuff.

It appears that the library doesn't take Unicode characters into account. You could:

- Try passing it the UTF-8 encoded string rather than the Unicode object, which is generally OK when working with a mostly-ASCII character set.

- Exchange the str() call for unicode(). unicode() is very likely what the library should use here anyway.

- Change your system default encoding to UTF-8. You can change this by editing site.py in the standard library; change the line that reads 'encoding = "ascii"'. This is not recommended, though, since it's not portable.

Shane
_______________________________________________
Ldsoss mailing list
[email protected]
http://lists.ldsoss.org/mailman/listinfo/ldsoss

Reply via email to