[Cython] How to deal with byte strings and unicode strings at the API level

Stefan Behnel stefan_ml at behnel.de
Fri May 9 21:48:16 CEST 2008


Hi again,

Stefan Behnel wrote:
> Lisandro Dalcin wrote:
>> or even try to coerce the input to ascii 8-bits if the input is 'unicode'
> 
> No, that's one of the problems why there is a lot of broken code in Python2:

Sorry, I misread your sentence here. You were asking how to fix your code and
I thought you meant Cython should do it for you (which it can't and also
shouldn't...)

If your input is unicode characters, then yes, encoding them to a well defined
byte sequence is the right thing to do.

Stefan


More information about the Cython-dev mailing list