开发者

How does one produce a specific unicode character with Python's C-API?

开发者 https://www.devze.com 2022-12-22 02:44 出处:网络
I\'m writing a Python extension that runs through a Py_UNICODE array, finds specific (ASCII, if it matters) characters, i.e. \'\\\' or \'\\n\', and does some additional stuff for each one that it find

I'm writing a Python extension that runs through a Py_UNICODE array, finds specific (ASCII, if it matters) characters, i.e. '\' or '\n', and does some additional stuff for each one that it finds.

I开发者_如何学编程s there a way to write those characters as literals? If not, what is the correct way to obtain Py_UNICODEs for them, keeping in mind that Py_UNICODE's size and internal representation may differ from system to system?


Use PyUnicode_FromWideChar() or one of the built-in codec decode functions.

0

精彩评论

暂无评论...
验证码 换一张
取 消