On Thu, Dec 3, 2009 at 4:50 AM, Stefan Behnel <[email protected]> wrote: > > 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. >
And you forgot mapping NULL to None... > > I think all of these are easy enough to type and read. So isn't that all we > need for that direction? > For brand-new code, I think you are right. > > Or is it really the encoding name that you want to > keep users from typing? > I think Robert's concern is the HUGE amount of code that should have to be reviewed/modified in SAGE. -- Lisandro Dalcín --------------- Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594 _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
