unicode codecs

Ivan Voras ivoras at __geri.cc.fer.hr
Mon Feb 9 18:13:21 EST 2004


Peter Otten wrote:

> You can either convert all strings to unicode or to iso-8859-2.
> A hands on approach:
> 
> 
>>>>u,s
> 
> (u'R\xfcbe', 'R\xfcbe')
> 
>>>>u+s
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 1:
> ordinal not in range(128)
> 
> This error is prevented by an explicit conversion:

Thank you - I eventually found that out the hard way :) It was a mix of 
some bugs from my code and the win32api library code, and I was seeing 
exeptions pop up from both of them depending on what conditions were 
met. Eventually I seem to have found a workaround for the library bugs 
but I don't like it - it's a mixup of using unicode and code-page and 
converting around when necessary. The good thing is that it doesn't seem 
to influence performance a lot...

(Apparently, win32file.FindFilesW does something with its parameter that 
breaks with above error when the parameter is unicode.)

Thanks for the help, all!



More information about the Python-list mailing list