0

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.

Is 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?

Johan Råde
  • 20,480
  • 21
  • 73
  • 110
DNS
  • 37,249
  • 18
  • 95
  • 132

1 Answers1

1

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

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358