summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2012-06-10 16:23:26 +0000
committerKai Huuhko <kai.huuhko@gmail.com>2012-06-10 16:23:26 +0000
commit34f582b5ba17eff27e38a06c90ad26809e8128b2 (patch)
tree58c7b586688b1d60e2328ab0bee216a2356fb9bd
parent3d4a7952288d4711b26747ae7c871e7eb0264ef0 (diff)
python-bindings: Adding _touni and _fruni for string conversions.
SVN revision: 71910
-rw-r--r--emotion/emotion.c_emotion.pyx13
1 files changed, 13 insertions, 0 deletions
diff --git a/emotion/emotion.c_emotion.pyx b/emotion/emotion.c_emotion.pyx
index 8f83d7a..88be35a 100644
--- a/emotion/emotion.c_emotion.pyx
+++ b/emotion/emotion.c_emotion.pyx
@@ -29,6 +29,19 @@ cdef int PY_REFCOUNT(object o):
29 cdef PyObject *obj = <PyObject *>o 29 cdef PyObject *obj = <PyObject *>o
30 return obj.ob_refcnt 30 return obj.ob_refcnt
31 31
32cdef unicode _touni(char* s):
33 return s.decode('UTF-8', 'strict')
34
35cdef char* _fruni(s):
36 cdef char* c_string
37 if isinstance(s, unicode):
38 string = s.encode('UTF-8')
39 c_string = string
40 elif isinstance(s, str):
41 c_string = s
42 else:
43 raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
44 return c_string
32 45
33cdef void _emotion_callback(void *data, 46cdef void _emotion_callback(void *data,
34 evas.c_evas.Evas_Object *o, void *ei) with gil: 47 evas.c_evas.Evas_Object *o, void *ei) with gil: