On Mon, Aug 25, 2008 at 12:36 PM, Jan Luebbe <[EMAIL PROTECTED]> wrote:
> Hi!
>
> When using unicode text from python with edje, it needs to be passed as
> a UTF-8 encoded string. To avoid doing this in the application, it
> should be handled in the bindings.
Hum, yep. We were handling that into our apps, but it would be good to
do it automatically, but this is not just python-edje, but python-evas
and even python-ecore, would you mind doing the patch for all of them?
> + def part_text_set(self, char *part, text):
> + cdef char *s
> + u = text.encode("utf8")
> + s = u
> + edje_object_part_text_set(self.obj, part, s)
i guess it's better to check for unicode (AFAIK str.encode will try to
decode to unicode and then encode, that using ascii codec, that will
fail with non-ascii chars):
cdef char *s
if isinstance(text, str):
s = text
elif isinstance(text, unicode):
s = text.encode('utf-8')
elif text is None:
s = NULL
else:
raise TypeError("unsupported type for parameter: text")
that will also handle None->NULL, which is not done ATM. Actually this
should be a cdef function to make he process easy:
cdef char *tostr(text) except NULL:
code...
> def part_text_get(self, char *part):
> - "@rtype: str"
> + "@rtype: unicode"
> cdef char *s
> s = edje_object_part_text_get(self.obj, part)
> if s == NULL:
> return None
> else:
> - return s
> + return s.decode("utf8")
Hum, I'm really not sure it if's good. Although I like unicode, it's
still slow on current CPython and going with str will avoid
conversions. Newer python (3.0 at least) will unify str and unicode,
making things even easier, so let's keep with str until then, do you
agree?
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [EMAIL PROTECTED]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel