src/cm/converters/__init__.py
changeset 119 5e8dda1b7631
parent 118 75d94dd14511
child 149 0f2c5744b39b
--- a/src/cm/converters/__init__.py	Mon Jan 25 09:23:32 2010 +0100
+++ b/src/cm/converters/__init__.py	Mon Jan 25 11:34:22 2010 +0100
@@ -1,5 +1,6 @@
 from pandoc_converters import pandoc_convert
 import chardet 
+from cm.utils.string import to_unicode 
 import re
 
 # TODO: move that in text_base: save images
@@ -7,19 +8,6 @@
     input = open(file_name, 'r').read()
     return _convert_from_mimetype(input, mime_type, format)
 
-def to_unicode(input):
-    if type(input) == str:
-        res = None
-        for encoding in [chardet.detect(input)['encoding'], 'utf8', 'latin1']:
-            try:
-                res = unicode(input, encoding)
-                break;
-            except UnicodeDecodeError:
-                pass
-        if not res:
-            raise Exception('UnicodeDecodeError: could not decode')
-        return res
-    return input
 
 def _convert_from_mimetype(input, mime_type, format):
     #input = to_unicode(input)