Browse Source

Encode/decode UTF-* properly

Alois Mahdal 9 years ago
parent
commit
96b9342e43
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      include/sardine.py

+ 4
- 4
include/sardine.py View File

126
         self.plugin = module.Plugin(self.plugindata)
126
         self.plugin = module.Plugin(self.plugindata)
127
 
127
 
128
     def _format_output(self, raw):
128
     def _format_output(self, raw):
129
-        suffix = "…"
130
-        cooked = raw
129
+        suffix = u'…'
130
+        cooked = raw.decode("utf-8")
131
         if self.plugindata.fmt == "plain":
131
         if self.plugindata.fmt == "plain":
132
             if self.plugindata.maxlen and len(raw) > self.plugindata.maxlen:
132
             if self.plugindata.maxlen and len(raw) > self.plugindata.maxlen:
133
                 newlen = self.plugindata.maxlen - len(suffix)
133
                 newlen = self.plugindata.maxlen - len(suffix)
134
-                cooked = raw[:newlen] + suffix
135
-        return cooked
134
+                cooked = cooked[:newlen] + suffix
135
+        return cooked.encode("utf-8")
136
 
136
 
137
     def get_output(self):
137
     def get_output(self):
138
         return self._format_output(self.plugin.render())
138
         return self._format_output(self.plugin.render())