VirtualMailManager/__init__.py
branchv0.6.x
changeset 174 974bafa59330
parent 162 0ac9ef587769
child 185 6e1ef32fbd82
--- a/VirtualMailManager/__init__.py	Fri Jan 22 04:31:38 2010 +0000
+++ b/VirtualMailManager/__init__.py	Sun Jan 24 06:40:38 2010 +0000
@@ -38,6 +38,12 @@
         _write('\n')
     os.sys.exit(code)
 
+def get_unicode(string):
+    """Converts `string` to `unicode`, if necessary."""
+    if isinstance(string, unicode):
+        return string
+    return unicode(string, ENCODING, 'replace')
+
 __all__ = [
         # imported modules
         'os', 're', 'locale',
@@ -46,6 +52,6 @@
         # error codes
         'ERR',
         # defined stuff
-        'ENCODING', 'w_std', 'w_err'
+        'ENCODING', 'get_unicode', 'w_std', 'w_err'
         ]
 # EOF