I used a Python SDK provided by a credit card processing company to access credit card transactions. Everything works fine except when I hit a customer address that contains foreign (e.g., accented) characters. In that case, depending on what I do, the script either crashes or it output garbled text.
For example, the following lines...
print u'\u0420\u043e\u0441\u0441\u0438\u044f'
print unicode(billTo.address)
print billTo.address.__class__
yield:
Россия
Nollekensweg �32
type 'lxml.objectify.StringElement'
Notice that the first line shows that unicode CAN be correctly printed. The second line illustrates the garbled address, where the three characters before '32' should presumably be a single accented or special character. The third line shows what kind of object billTo.address is.
Also, if I try using "print billTo.address" instead of "print unicode(billTo.address)", the program throws an error.
Any ideas what I need to do to correctly retrieve and print the contents of billTo.address? Note that I have no control over what the software I've been given puts into that object.
EDIT: Adding the traceback:
`Traceback (most recent call last):
File "get_transaction_details.py", line 352, in <module>
download_transaction_details('8386560251')
File "get_transaction_details.py", line 237, in download_transaction_details
print billTo.address
UnicodeEncodeError: 'ascii' codec can't encode characters in position 13-15: ordinal not in range(128)`