我需要在各种编码的python对象和c字符串之间进行转换。从AC串去使用PyUnicode_Decode,但林不知道如何走另一条路Python c-api和unicode字符串
//char* can be a wchar_t or any other element size, just make sure it is correctly terminated for its encoding
Unicode(const char *str, size_t bytes, const char *encoding="utf-16", const char *errors="strict")
:Object(PyUnicode_Decode(str, bytes, encoding, errors))
{
//check for any python exceptions
ExceptionCheck();
}
我要创建另一个函数,采用Python的Unicode字符串,并使用其放入缓冲区为Unicode对象是相当简单的给定encodeing,如:
我怀疑它具有财产以后做然而PyUnicode_AsEncodedString一个返回的PyObject,所以我不知道如何将它放入我的缓冲区...
注:两上面的方法是C++ Unicode的成员类封装了Python API中 我使用Python 3.0