[kupfer] objects, plugin.selection: fix unicode handling
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] objects, plugin.selection: fix unicode handling
- Date: Thu, 20 Aug 2009 22:10:28 +0000 (UTC)
commit 42bd3b6ab12f2c7121738d3c299e20679bb0e7a8
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Wed Aug 19 14:11:22 2009 +0200
objects, plugin.selection: fix unicode handling
We have to ensure text are as unicode objects before we slice or part
the strings, unless we want to split unicode characters in the middle.
kupfer/objects.py | 3 ++-
kupfer/plugin/selection.py | 2 ++
2 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/kupfer/objects.py b/kupfer/objects.py
index f42386d..c601184 100644
--- a/kupfer/objects.py
+++ b/kupfer/objects.py
@@ -1115,10 +1115,11 @@ class TextLeaf (Leaf):
"""
def __init__(self, text, name=None):
"""@text *must* be unicode or UTF-8 str"""
+ text = tounicode(text)
if not name:
lines = [l for l in text.splitlines() if l.strip()]
name = lines[0] if lines else text
- Leaf.__init__(self, tounicode(text), name)
+ Leaf.__init__(self, text, name)
def get_actions(self):
return ()
diff --git a/kupfer/plugin/selection.py b/kupfer/plugin/selection.py
index 95bd8a5..dd1a6e9 100644
--- a/kupfer/plugin/selection.py
+++ b/kupfer/plugin/selection.py
@@ -1,6 +1,7 @@
import gtk
from kupfer.objects import Source, Leaf, TextLeaf, SourceLeaf, PicklingHelperMixin
+from kupfer import objects
__kupfer_name__ = _("Selected Text")
__kupfer_sources__ = ("SelectionSource", )
@@ -10,6 +11,7 @@ __author__ = "Ulrik Sverdrup <ulrik sverdrup gmail com>"
class SelectedText (TextLeaf):
def __init__(self, text):
+ text = objects.tounicode(text)
lines = filter(None, text.splitlines())
summary = lines[0] if lines else text
maxlen = 10
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]