From c89bc07e0bc57b73fbb099e7e458b41ecb739cc9 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 7 May 2007 00:18:42 -0400 Subject: [PATCH] Fix nickname encoding and length issues --- shell/intro/intro.py | 4 +++- sugar/profile.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/shell/intro/intro.py b/shell/intro/intro.py index 38c0a7be..2ae097de 100644 --- a/shell/intro/intro.py +++ b/shell/intro/intro.py @@ -185,6 +185,7 @@ class EntryBox(hippo.CanvasBox, hippo.CanvasItem): self.append(self._label) self._entry = gtk.Entry() + self._entry.set_max_length(45) entry_item = hippo.CanvasWidget(widget=self._entry) self.append(entry_item) @@ -297,7 +298,8 @@ class IntroWindow(gtk.Window): section = 'Buddy' if not cp.has_section(section): cp.add_section(section) - cp.set(section, 'NickName', name) + # encode nickname to ascii-safe characters + cp.set(section, 'NickName', name.encode("utf-8")) cp.set(section, 'Color', color.to_string()) section = 'Server' diff --git a/sugar/profile.py b/sugar/profile.py index 840e101c..8041a4e1 100644 --- a/sugar/profile.py +++ b/sugar/profile.py @@ -66,7 +66,9 @@ class _Profile(object): parsed = cp.read([config_path]) if cp.has_option('Buddy', 'NickName'): - self.name = cp.get('Buddy', 'NickName') + name = cp.get('Buddy', 'NickName') + # decode nickname from ascii-safe chars to unicode + self.name = name.decode("utf-8") if cp.has_option('Buddy', 'Color'): self.color = XoColor(cp.get('Buddy', 'Color'))