[Python-Dev] 3.0 C API to decode bytes into unicode?
I cannot see how I implement decode() for bytes objects using the C API for PyCXX library, I'd assuming that I should find a PyBytes_Decode function but cannot find it in beta 2. What is the preferred way to do this? Barry ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] 3.0 C API to decode bytes into unicode?
On Fri, Aug 1, 2008 at 8:06 AM, Barry Scott <[EMAIL PROTECTED]> wrote: > I cannot see how I implement decode() for bytes objects using the C API > for PyCXX library, > > I'd assuming that I should find a PyBytes_Decode function but cannot find it > in beta 2. > > What is the preferred way to do this? PyObject_CallMethod(bytesobj, "decode", "") PyUnicode_FromEncodedObject takes an encoding argument. > > Barry > > ___ > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/musiccomposition%40gmail.com > -- Cheers, Benjamin Peterson "There's no place like 127.0.0.1." ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] 3.0 C API to decode bytes into unicode?
On 2008-08-01 15:06, Barry Scott wrote: I cannot see how I implement decode() for bytes objects using the C API for PyCXX library, I'd assuming that I should find a PyBytes_Decode function but cannot find it in beta 2. What is the preferred way to do this? PyUnicode_FromEncodedObject() should to the trick. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Aug 01 2008) >>> Python/Zope Consulting and Support ...http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] 3.0 C API to decode bytes into unicode?
Benjamin Peterson wrote: > On Fri, Aug 1, 2008 at 8:06 AM, Barry Scott <[EMAIL PROTECTED]> wrote: >> I cannot see how I implement decode() for bytes objects using the C API >> for PyCXX library, >> >> I'd assuming that I should find a PyBytes_Decode function but cannot find it >> in beta 2. >> >> What is the preferred way to do this? > > PyObject_CallMethod(bytesobj, "decode", "") > > PyUnicode_FromEncodedObject takes an encoding argument. There is also PyCodec_Decode() but it does not seem to be documented, nor is any function declared in codecs.h. Is it part of the public API? -- Amaury Forgeot d'Arc ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] 3.0 C API to decode bytes into unicode?
On 2008-08-01 15:38, Amaury Forgeot d'Arc wrote: Benjamin Peterson wrote: On Fri, Aug 1, 2008 at 8:06 AM, Barry Scott <[EMAIL PROTECTED]> wrote: I cannot see how I implement decode() for bytes objects using the C API for PyCXX library, I'd assuming that I should find a PyBytes_Decode function but cannot find it in beta 2. What is the preferred way to do this? PyObject_CallMethod(bytesobj, "decode", "") PyUnicode_FromEncodedObject takes an encoding argument. There is also PyCodec_Decode() but it does not seem to be documented, nor is any function declared in codecs.h. Is it part of the public API? Yes, of course. I guess I never got around to writing docs for it at the time. This should basically just be a matter of converting the header file codecs.h into ReST. The APIs are all documented in that header file. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Aug 01 2008) >>> Python/Zope Consulting and Support ...http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] 3.0 C API to decode bytes into unicode?
On Aug 1, 2008, at 14:30, M.-A. Lemburg wrote: On 2008-08-01 15:06, Barry Scott wrote: I cannot see how I implement decode() for bytes objects using the C API for PyCXX library, I'd assuming that I should find a PyBytes_Decode function but cannot find it in beta 2. What is the preferred way to do this? PyUnicode_FromEncodedObject() should to the trick. Thanks thats what I've use. Barry ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com