unicode codecs

Ivan Voras ivoras at __geri.cc.fer.hr
Mon Feb 9 17:57:30 EST 2004


Martin v. Löwis wrote:
> Ivan Voras wrote:
> 
>> - win32api function returns a string (8bit) with some of the 
>> characters from the upper half of code page, let's call it s1
> 
> 
> Are you absolutely certain that type(s1) is str?

Yes. Plain string.

>> - a statement such as a='x'+s1 fails with the above error.
> 
> 
> Are you absolutely certain the constant is the literal string 'x'?

Um, what else could it be? This is an example, in the real case the 
literal string is something else (but of the same format).


>> - call the unicode version of function. Returned is a unicode string 
>> (checked, it really is unicode) like u'R\xfcgenwald.txt', let's call 
>> it s2
>> - a statement a='x'+s2.encode('iso-8859-2') also fails with the exact 
>> same error.
> 
> How do you know it is the concatenation that causes the exception?

What else could cause it? It's a simple command, nothing fancy - an 
concatenation and assignment.

I've tried converting everything to use unicode and I'm getting *really* 
weird results now - it may be a bug in the win32api library.



More information about the Python-list mailing list