Commits

Jerónimo Albi committed df1501f Draft

Added function to handle unicode strings

Comments (0)

Files changed (1)

shrink/compatibility.py

 import sys
 
 
+# define a function to handle str types
+if sys.version < '3':
+    import codecs
+
+    def u(text):
+        # return a unicode text
+        return codecs.unicode_escape_decode(text)[0]
+else:
+    def u(text):
+        # leave text as it is
+        return text
+
+
 def print_text(text, *args, **kwargs):
     """Print a text to standar output