Commits

Antoine Nguyen  committed d45266a

Use the *encode* method to properly convert a unicode object to a string one.

see #6

  • Participants
  • Parent commits e531098

Comments (0)

Files changed (2)

File sievelib/commands.py

                     value.tosieve(indentlevel, target=target)
                     continue
 
+                if type(value) is unicode:
+                    value = value.encode("utf-8")
+
                 if "tag" in arg["type"] and arg.get("write_tag", False):
                     target.write("%s " % arg["values"][0])
 

File sievelib/managesieve.py

         ret = []
         for a in args:
             if type(a) in [str, unicode] and self.__size_expr.match(a) is None:
-                ret += ['"%s"' % a]
+                ret += ['"%s"' % a.encode('utf-8')]
                 continue
             ret += ["%s" % str(a)]
         return ret
         :rtype: boolean
         """
         if type(content) is unicode:
-            content = str(content)
+            content = content.encode("utf-8")
 
         content = "{%d+}%s%s" % (len(content), CRLF, content)
         code, data = \