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
commitde37226d5ccb5cc37d227e1e9692b4389af49c21 (patch)
tree4c34fb79b375f299b486b5a907355f7afa307ffd
parentce0161ba74ee8e482c3649d2651549f76dbffa36 (diff)
python-bindings: Adding _touni and _fruni for string conversions.
SVN revision: 71910
-rw-r--r--edje/edje.c_edje.pyx14
1 files changed, 14 insertions, 0 deletions
diff --git a/edje/edje.c_edje.pyx b/edje/edje.c_edje.pyx
index 59e5dda..18ef588 100644
--- a/edje/edje.c_edje.pyx
+++ b/edje/edje.c_edje.pyx
@@ -30,6 +30,20 @@ cdef int PY_REFCOUNT(object o):
30 cdef PyObject *obj = <PyObject *>o 30 cdef PyObject *obj = <PyObject *>o
31 return obj.ob_refcnt 31 return obj.ob_refcnt
32 32
33cdef unicode _touni(char* s):
34 return s.decode('UTF-8', 'strict')
35
36cdef char* _fruni(s):
37 cdef char* c_string
38 if isinstance(s, unicode):
39 string = s.encode('UTF-8')
40 c_string = string
41 elif isinstance(s, str):
42 c_string = s
43 else:
44 raise TypeError("Expected str or unicode object, got %s" % (type(s).__name__))
45 return c_string
46
33def init(): 47def init():
34 cdef int r = edje_init() 48 cdef int r = edje_init()
35 49