Re: Problems in Using C-API for Unicode handling

2009-01-13 Thread Scott David Daniels
abhi wrote: On Jan 13, 12:17 pm, Terry Reedy wrote: abhi wrote: Hi, I am trying to handle Unicode objects in C (Python 2.5.2) ... I want to convert this explicitely to utf-16 You are trying to get Unicode and UTF-16, whereas you should think of those two as distinct. UTF-16 is a

Re: Problems in Using C-API for Unicode handling

2009-01-13 Thread Stefan Behnel
abhi wrote: > Now I want to utf-16 so I am trying to use the first one, but it is > giving back NULL in case of PyObject is already Unicode type which is > expected. What puzzles me is that PyUnicode_FromObject(PyObject *obj) > is passing irrespective of type of PyObject. The API says it is > Short

Re: Problems in Using C-API for Unicode handling

2009-01-13 Thread Steve Holden
abhi wrote: > On Jan 13, 12:17 pm, Terry Reedy wrote: >> abhi wrote: >>> Hi, >>> I am trying to handle Unicode objects in C (Python 2.5.2). I am >>> getting PyObjects from and want to coerce them to unicode objects. The >>> documentation provides two APIs for that: >>> PyUnicode_FromEncodedOb

Re: Problems in Using C-API for Unicode handling

2009-01-13 Thread abhi
On Jan 13, 12:17 pm, Terry Reedy wrote: > abhi wrote: > > Hi, > >     I am trying to handle Unicode objects in C (Python 2.5.2). I am > > getting PyObjects from and want to coerce them to unicode objects. The > > documentation provides two APIs for that: > > >  PyUnicode_FromEncodedObject(PyObject

Re: Problems in Using C-API for Unicode handling

2009-01-12 Thread Terry Reedy
abhi wrote: Hi, I am trying to handle Unicode objects in C (Python 2.5.2). I am getting PyObjects from and want to coerce them to unicode objects. The documentation provides two APIs for that: PyUnicode_FromEncodedObject(PyObject *obj, const char *encoding, const char *errors) PyUnicode_Fr

Problems in Using C-API for Unicode handling

2009-01-12 Thread abhi
Hi, I am trying to handle Unicode objects in C (Python 2.5.2). I am getting PyObjects from and want to coerce them to unicode objects. The documentation provides two APIs for that: PyUnicode_FromEncodedObject(PyObject *obj, const char *encoding, const char *errors) PyUnicode_FromObject(PyObj