Index: pykota/trunk/checkdeps.py
===================================================================
--- pykota/trunk/checkdeps.py (revision 3275)
+++ pykota/trunk/checkdeps.py (revision 3287)
@@ -81,5 +81,4 @@
                        ("Python-PAM", "PAM", "Python-PAM is recommended if you plan to use pknotify+PyKotIcon.\nGrab it from http://www.pangalactic.org/PyPAM/"),
                        ("Python-pkipplib", "pkipplib", "Python-pkipplib is now mandatory.\nGrab it from http://www.pykota.com/software/pkipplib/"),
-                       ("Python-chardet", "chardet", "Python-chardet is recommended.\nGrab it from http://chardet.feedparser.org/"),
                      ]
     commandstocheck = [ ("GhostScript", "gs", "Depending on your configuration, GhostScript may be needed in different parts of PyKota."),
Index: pykota/trunk/debian/control
===================================================================
--- pykota/trunk/debian/control (revision 3259)
+++ pykota/trunk/debian/control (revision 3287)
@@ -11,5 +11,5 @@
 Architecture: all
 Depends: python, python-egenix-mxdatetime, cupsys,  python-pygresql | python-ldap | python-pysqlite2 | python-mysqldb, jaxml | python-jaxml, python-osd, python-reportlab, python-pysnmp4, python-imaging 
-Recommends: qa-assistant, snmp, netatalk, python-psyco, npadmin, python-pam, python-chardet
+Recommends: qa-assistant, snmp, netatalk, python-psyco, npadmin, python-pam
 Description: Print Quota/Accounting system for CUPS
  PyKota is a full featured, internationalized, centralized and extensible 
Index: pykota/trunk/README
===================================================================
--- pykota/trunk/README (revision 3282)
+++ pykota/trunk/README (revision 3287)
@@ -154,8 +154,7 @@
     - The Python-OSD module to use the graphical print quota reminder.
       (http://repose.cx/pyosd/)
-    - The Python-chardet module to autodetect user's character set when  
-      printing. (http://chardet.feedparser.org)
     - SNMP tools (specifically the snmpget command) if you prefer to
-      use your own script to request query printers.
+      use your own script to request query printers instead of PyKota's
+      internal SNMP handling facilities, which is not recommanded...
       (http://www.net-snmp.org)
     - Netatalk (specifically the pap command) if you plan to
Index: pykota/trunk/pykota/tool.py
===================================================================
--- pykota/trunk/pykota/tool.py (revision 3286)
+++ pykota/trunk/pykota/tool.py (revision 3287)
@@ -39,15 +39,4 @@
 from mx import DateTime
 
-try :
-    import chardet
-except ImportError :    
-    def detectCharset(text) :
-        """Fakes a charset detection if the chardet module is not installed."""
-        return "ISO-8859-15"
-else :    
-    def detectCharset(text) :
-        """Uses the chardet module to workaround CUPS lying to us."""
-        return chardet.detect(text)["encoding"] or "UTF-8"
-
 from pykota import config, storage, logger
 from pykota.version import __version__, __author__, __years__, __gplblurb__
@@ -63,5 +52,5 @@
         Exception.__init__(self, message)
     def __repr__(self):
-        return self.message
+        return self.message.encode(sys.stdout.encoding or "UTF-8", "replace")
     __str__ = __repr__
     
@@ -142,5 +131,5 @@
             self.charset = self.charset or locale.getpreferredencoding()
         except locale.Error :    
-            self.charset = sys.getfilesystemencoding()
+            self.charset = sys.stdout.encoding or sys.getfilesystemencoding()
         
         # Dirty hack : if the charset is ASCII, we can safely use UTF-8 instead
@@ -158,7 +147,7 @@
             except TypeError : # Python <2.4
                 trans = gettext.translation("pykota", languages=["%s.%s" % (self.language, self.charset)])
-            trans.install()
+            trans.install(unicode=True)
         except :
-            gettext.NullTranslations().install()
+            gettext.NullTranslations().install(unicode=True)
     
         # pykota specific stuff
@@ -215,13 +204,6 @@
         if text is None :
             return None
-        try :
-            return text.decode("UTF-8").encode(self.charset, "replace") 
-        except (UnicodeError, AttributeError) :    
-            try :
-                # Maybe already in Unicode ?
-                return text.encode(self.charset, "replace") 
-            except (UnicodeError, AttributeError) :
-                # Try to autodetect the charset
-                return text.decode(detectCharset(text), "replace").encode(self.charset, "replace")
+        else :    
+            return text.decode("UTF-8", "replace").encode(self.charset, "replace") 
         
     def userCharsetToUTF8(self, text) :
@@ -229,28 +211,12 @@
         if text is None :
             return None
-        try :
-            # We don't necessarily trust the default charset, because
-            # xprint sends us titles in UTF-8 but CUPS gives us an ISO-8859-1 charset !
-            # So we first try to see if the text is already in UTF-8 or not, and
-            # if it is, we delete characters which can't be converted to the user's charset,
-            # then convert back to UTF-8. PostgreSQL 7.3.x used to reject some unicode characters,
-            # this is fixed by the ugly line below :
-            return text.decode("UTF-8").encode(self.charset, "replace").decode(self.charset).encode("UTF-8", "replace")
-        except (UnicodeError, AttributeError) :
-            try :
-                return text.decode(self.charset).encode("UTF-8", "replace") 
-            except (UnicodeError, AttributeError) :    
-                try :
-                    # Maybe already in Unicode ?
-                    return text.encode("UTF-8", "replace") 
-                except (UnicodeError, AttributeError) :
-                    # Try to autodetect the charset
-                    return text.decode(detectCharset(text), "replace").encode("UTF-8", "replace")
-        return newtext
+        else :    
+            return text.decode(self.charset, "replace").encode("UTF-8", "replace")    
         
     def display(self, message) :
         """Display a message but only if stdout is a tty."""
         if sys.stdout.isatty() :
-            sys.stdout.write(message)
+            sys.stdout.write(message.encode(sys.stdout.encoding or "UTF-8", \
+                                            "replace"))
             sys.stdout.flush()
             
@@ -258,9 +224,15 @@
         """Logs something to debug output if debug is enabled."""
         if self.debug :
-            self.logger.log_message(message, "debug")
+            self.logger.log_message(message.encode(sys.stdout.encoding \
+                                                       or "UTF-8", \
+                                                   "replace"), \
+                                    "debug")
             
     def printInfo(self, message, level="info") :        
         """Sends a message to standard error."""
-        sys.stderr.write("%s: %s\n" % (level.upper(), message))
+        sys.stderr.write("%s: %s\n" % (level.upper(), \
+                                       message.encode(sys.stdout.encoding \
+                                                          or "UTF-8", \
+                                                      "replace")))
         sys.stderr.flush()
         
Index: pykota/trunk/bin/pksetup
===================================================================
--- pykota/trunk/bin/pksetup (revision 3275)
+++ pykota/trunk/bin/pksetup (revision 3287)
@@ -190,5 +190,4 @@
                  "python-imaging",
                  "python-pysnmp4",
-                 "python-chardet",
                  "python-pam" ]
         
Index: pykota/trunk/qa-assistant/pykota.xml
===================================================================
--- pykota/trunk/qa-assistant/pykota.xml (revision 3212)
+++ pykota/trunk/qa-assistant/pykota.xml (revision 3287)
@@ -172,18 +172,4 @@
       </description>
     </entry>
-    <entry name="python-chardet" display="true">
-      <states>
-        <state name="Pass">python-chardet is installed</state>
-        <state name="Fail">python-chardet is not installed</state>
-        <state name="Non-Blocker">Our system is correctly configured and up-to-date so PyKota won't need this module</state>
-      </states>
-      <description>
-        python-chardet allows PyKota to automatically detect the character set used in a print job's textual information (like its title)
-        in the case your system and/or installed release of CUPS doesn't produce UTF-8.
-        It can also be useful when dumping incorrectly encoded database contents (because of the problem mentioned
-        above).
-        You can install it with 'apt-get install python-chardet'
-      </description>
-    </entry>
     <entry name="python-pam" display="true">
       <states>
