Skip to content

Instantly share code, notes, and snippets.

@david-batranu
Created December 21, 2018 17:21
Show Gist options
  • Save david-batranu/1522acaae850a1cd78251e16dadba4f6 to your computer and use it in GitHub Desktop.
Save david-batranu/1522acaae850a1cd78251e16dadba4f6 to your computer and use it in GitHub Desktop.
#include <Python.h>
int main(int argc, char *argv[]) {
const char *s1 = "șustă";
PyUnicodeObject *uo_s1 = PyUnicode_FromString(s1);
Py_ssize_t s_s1 = PyUnicode_GetSize(uo_s1);
Py_UNICODE *c_s1 = PyUnicode_AS_UNICODE(uo_s1);
printf("SUP!: %li\n", s_s1);
for (int i = 0; i < s_s1; i++) {
printf("%i: %c\n", i, c_s1[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment