Robert Bradshaw, 03.12.2009 02:01: > On Dec 1, 2009, at 12:56 AM, Stefan Behnel wrote: >> We could have a "cython.str()" function that converts char*+length or >> a char* buffer to bytes or unicode depending on the platform and using >> either the platform encoding or a different one passed as argument. >> So you'd return "cython.str(c_string, length)" (or "cython.str(s)" for >> the example above) and be happy. > > That's a good idea, and should probably go in regardless of whatever > else happens.
Ok, so then we have three different cases for the char*->Python path: 1) create bytes - that's what currently happens automatically 2) create unicode - easy to do with "s.decode(enc)" 3) create str (i.e. bytes in Py2 and unicode in Py3) - easy to do with a future "cython.str(s)" or "cython.str(s[:length])", optionally taking an encoding as second argument and defaulting to the platform encoding otherwise. I think all of these are easy enough to type and read. So isn't that all we need for that direction? Or is it really the encoding name that you want to keep users from typing? Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
