From b6f2a6822f36be6ddc017e4d78bc3d29c8cbe1ee Mon Sep 17 00:00:00 2001 From: Kai Huuhko Date: Wed, 14 May 2014 07:01:57 +0300 Subject: [PATCH] efl.ecore.x: Unicode handling --- efl/ecore/x.pyx | 9 +++------ efl/ecore/x_events.pxi | 11 ++++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/efl/ecore/x.pyx b/efl/ecore/x.pyx index ef1bd66..d75c587 100644 --- a/efl/ecore/x.pyx +++ b/efl/ecore/x.pyx @@ -17,6 +17,7 @@ #from cpython cimport PyObject, Py_INCREF, Py_DECREF from cpython cimport PyMem_Malloc, PyMem_Free +from libc.string cimport PyUnicode_AsUTF8String def init(name=None): @@ -25,13 +26,9 @@ def init(name=None): :param name: display target name, if None, default will be used. :rtype: int """ - cdef char *s cdef int i - if name is None: - s = NULL - else: - s = name - i = ecore_x_init(s) + if isinstance(name, unicode): name = PyUnicode_AsUTF8String(name) + i = ecore_x_init(s if name is not None else NULL) x_events_register() return i diff --git a/efl/ecore/x_events.pxi b/efl/ecore/x_events.pxi index 680239e..b605899 100644 --- a/efl/ecore/x_events.pxi +++ b/efl/ecore/x_events.pxi @@ -16,12 +16,13 @@ # along with this Python-EFL. If not, see . from efl.ecore cimport EventHandler +from efl.utils.conversions cimport _ctouni as _charp_to_str -cdef object _charp_to_str(const char *p): - if p != NULL: - return p - else: - return None +# cdef object _charp_to_str(const char *p): +# if p != NULL: +# return p +# else: +# return None cdef class EventKey(Event):