Index: pykota/trunk/pykota/storages/pgstorage.py
===================================================================
--- pykota/trunk/pykota/storages/pgstorage.py (revision 3288)
+++ pykota/trunk/pykota/storages/pgstorage.py (revision 3291)
@@ -154,5 +154,5 @@
                     field = fields[j]
                     if type(field) == StringType :
-                        fields[j] = self.databaseToUserCharset(field) 
+                        fields[j] = self.databaseToUnicode(field) 
                 entries[i] = tuple(fields)    
             return entries
Index: pykota/trunk/pykota/storages/sql.py
===================================================================
--- pykota/trunk/pykota/storages/sql.py (revision 3275)
+++ pykota/trunk/pykota/storages/sql.py (revision 3291)
@@ -36,5 +36,5 @@
         user.LifeTimePaid = record.get("lifetimepaid")
         user.Email = record.get("email")
-        user.Description = self.databaseToUserCharset(record.get("description"))
+        user.Description = self.databaseToUnicode(record.get("description"))
         user.OverCharge = record.get("overcharge", 1.0)
         user.Exists = True
@@ -48,5 +48,5 @@
         group.AccountBalance = record.get("balance")
         group.LifeTimePaid = record.get("lifetimepaid")
-        group.Description = self.databaseToUserCharset(record.get("description"))
+        group.Description = self.databaseToUnicode(record.get("description"))
         group.Exists = True
         return group
@@ -64,5 +64,5 @@
         else :
             printer.PassThrough = False
-        printer.Description = self.databaseToUserCharset(record.get("description") or "") # TODO : is 'or ""' still needed ?
+        printer.Description = self.databaseToUnicode(record.get("description") or "") # TODO : is 'or ""' still needed ?
         printer.Exists = True
         return printer
@@ -76,8 +76,8 @@
         job.JobPrice = record.get("jobprice")
         job.JobAction = record.get("action")
-        job.JobFileName = self.databaseToUserCharset(record.get("filename") or "") 
-        job.JobTitle = self.databaseToUserCharset(record.get("title") or "") 
+        job.JobFileName = self.databaseToUnicode(record.get("filename") or "") 
+        job.JobTitle = self.databaseToUnicode(record.get("title") or "") 
         job.JobCopies = record.get("copies")
-        job.JobOptions = self.databaseToUserCharset(record.get("options") or "") 
+        job.JobOptions = self.databaseToUnicode(record.get("options") or "") 
         job.JobDate = record.get("jobdate")
         job.JobHostName = record.get("hostname")
@@ -85,9 +85,9 @@
         job.JobMD5Sum = record.get("md5sum")
         job.JobPages = record.get("pages")
-        job.JobBillingCode = self.databaseToUserCharset(record.get("billingcode") or "")
+        job.JobBillingCode = self.databaseToUnicode(record.get("billingcode") or "")
         job.PrecomputedJobSize = record.get("precomputedjobsize")
         job.PrecomputedJobPrice = record.get("precomputedjobprice")
-        job.UserName = self.databaseToUserCharset(record.get("username"))
-        job.PrinterName = self.databaseToUserCharset(record.get("printername"))
+        job.UserName = self.databaseToUnicode(record.get("username"))
+        job.PrinterName = self.databaseToUnicode(record.get("printername"))
         if job.JobTitle == job.JobFileName == job.JobOptions == "hidden" :
             (job.JobTitle, job.JobFileName, job.JobOptions) = (_("Hidden because of privacy concerns"),) * 3
@@ -138,5 +138,5 @@
         code = StorageBillingCode(self, billingcode)
         code.ident = record.get("id")
-        code.Description = self.databaseToUserCharset(record.get("description") or "") # TODO : is 'or ""' still needed ?
+        code.Description = self.databaseToUnicode(record.get("description") or "") # TODO : is 'or ""' still needed ?
         code.Balance = record.get("balance") or 0.0
         code.PageCounter = record.get("pagecounter") or 0
@@ -149,5 +149,5 @@
             expressions = []
             for (k, v) in only.items() :
-                expressions.append("%s=%s" % (k, self.doQuote(self.userCharsetToDatabase(v))))
+                expressions.append("%s=%s" % (k, self.doQuote(self.unicodeToDatabase(v))))
             return " AND ".join(expressions)     
         return ""        
@@ -299,5 +299,5 @@
                 self.tool.printInfo("Object %s has no %s attribute !" % (repr(record), attribute), "error")
             else :
-                attrval = self.databaseToUserCharset(attrval)
+                attrval = self.databaseToUnicode(attrval)
                 if patterns :
                     if (not isinstance(patterns, type([]))) and (not isinstance(patterns, type(()))) :
@@ -351,5 +351,5 @@
         """Extracts user information given its name."""
         result = self.doSearch("SELECT * FROM users WHERE username=%s"\
-                      % self.doQuote(self.userCharsetToDatabase(username)))
+                      % self.doQuote(self.unicodeToDatabase(username)))
         if result :
             return self.storageUserFromRecord(username, result[0])
@@ -360,5 +360,5 @@
         """Extracts group information given its name."""
         result = self.doSearch("SELECT groups.*,COALESCE(SUM(balance), 0.0) AS balance, COALESCE(SUM(lifetimepaid), 0.0) AS lifetimepaid FROM groups LEFT OUTER JOIN users ON users.id IN (SELECT userid FROM groupsmembers WHERE groupid=groups.id) WHERE groupname=%s GROUP BY groups.id,groups.groupname,groups.limitby,groups.description" \
-                      % self.doQuote(self.userCharsetToDatabase(groupname)))
+                      % self.doQuote(self.unicodeToDatabase(groupname)))
         if result :
             return self.storageGroupFromRecord(groupname, result[0])
@@ -369,5 +369,5 @@
         """Extracts printer information given its name."""
         result = self.doSearch("SELECT * FROM printers WHERE printername=%s" \
-                      % self.doQuote(self.userCharsetToDatabase(printername)))
+                      % self.doQuote(self.unicodeToDatabase(printername)))
         if result :
             return self.storagePrinterFromRecord(printername, result[0])
@@ -378,5 +378,5 @@
         """Extracts a billing code information given its name."""
         result = self.doSearch("SELECT * FROM billingcodes WHERE billingcode=%s" \
-                      % self.doQuote(self.userCharsetToDatabase(label)))
+                      % self.doQuote(self.unicodeToDatabase(label)))
         if result :
             return self.storageBillingCodeFromRecord(label, result[0])
@@ -416,5 +416,5 @@
         if result :
             for record in result :
-                user = self.storageUserFromRecord(self.databaseToUserCharset(record.get("username")), \
+                user = self.storageUserFromRecord(self.databaseToUnicode(record.get("username")), \
                                                   record)
                 groupmembers.append(user)
@@ -428,5 +428,5 @@
         if result :
             for record in result :
-                groups.append(self.getGroup(self.databaseToUserCharset(record.get("groupname"))))
+                groups.append(self.getGroup(self.databaseToUnicode(record.get("groupname"))))
         return groups        
         
@@ -438,5 +438,5 @@
             for record in result :
                 if record["groupid"] != printer.ident : # in case of integrity violation
-                    parentprinter = self.getPrinter(self.databaseToUserCharset(record.get("printername")))
+                    parentprinter = self.getPrinter(self.databaseToUnicode(record.get("printername")))
                     if parentprinter.Exists :
                         pgroups.append(parentprinter)
@@ -460,5 +460,5 @@
                     patdict[p] = None
             for record in result :
-                pname = self.databaseToUserCharset(record["printername"])
+                pname = self.databaseToUnicode(record["printername"])
                 if patdict.has_key(pname) or self.tool.matchString(pname, patterns) :
                     printer = self.storagePrinterFromRecord(pname, record)
@@ -484,5 +484,5 @@
                     patdict[p] = None
             for record in result :
-                uname = self.databaseToUserCharset(record["username"])
+                uname = self.databaseToUnicode(record["username"])
                 if patdict.has_key(uname) or self.tool.matchString(uname, patterns) :
                     user = self.storageUserFromRecord(uname, record)
@@ -508,5 +508,5 @@
                     patdict[p] = None
             for record in result :
-                gname = self.databaseToUserCharset(record["groupname"])
+                gname = self.databaseToUnicode(record["groupname"])
                 if patdict.has_key(gname) or self.tool.matchString(gname, patterns) :
                     group = self.storageGroupFromRecord(gname, record)
@@ -529,5 +529,5 @@
                     patdict[p] = None
             for record in result :
-                codename = self.databaseToUserCharset(record["billingcode"])
+                codename = self.databaseToUnicode(record["billingcode"])
                 if patdict.has_key(codename) or self.tool.matchString(codename, patterns) :
                     code = self.storageBillingCodeFromRecord(codename, record)
@@ -542,5 +542,5 @@
         if result :
             for record in result :
-                uname = self.databaseToUserCharset(record.get("username"))
+                uname = self.databaseToUnicode(record.get("username"))
                 if self.tool.matchString(uname, names) :
                     user = self.storageUserFromRecord(uname, record)
@@ -557,5 +557,5 @@
         if result :
             for record in result :
-                gname = self.databaseToUserCharset(record.get("groupname"))
+                gname = self.databaseToUnicode(record.get("groupname"))
                 if self.tool.matchString(gname, names) :
                     group = self.getGroup(gname)
@@ -570,8 +570,8 @@
             return oldentry
         self.doModify("INSERT INTO printers (printername, passthrough, maxjobsize, description, priceperpage, priceperjob) VALUES (%s, %s, %s, %s, %s, %s)" \
-                          % (self.doQuote(self.userCharsetToDatabase(printer.Name)), \
+                          % (self.doQuote(self.unicodeToDatabase(printer.Name)), \
                              self.doQuote((printer.PassThrough and "t") or "f"), \
                              self.doQuote(printer.MaxJobSize or 0), \
-                             self.doQuote(self.userCharsetToDatabase(printer.Description)), \
+                             self.doQuote(self.unicodeToDatabase(printer.Description)), \
                              self.doQuote(printer.PricePerPage or 0.0), \
                              self.doQuote(printer.PricePerJob or 0.0)))
@@ -585,8 +585,8 @@
             return oldentry
         self.doModify("INSERT INTO billingcodes (billingcode, balance, pagecounter, description) VALUES (%s, %s, %s, %s)" \
-                           % (self.doQuote(self.userCharsetToDatabase(bcode.BillingCode)), 
+                           % (self.doQuote(self.unicodeToDatabase(bcode.BillingCode)), 
                               self.doQuote(bcode.Balance or 0.0), \
                               self.doQuote(bcode.PageCounter or 0), \
-                              self.doQuote(self.userCharsetToDatabase(bcode.Description))))
+                              self.doQuote(self.unicodeToDatabase(bcode.Description))))
         bcode.isDirty = False
         return None # the entry created doesn't need further modification
@@ -598,5 +598,5 @@
             return oldentry
         self.doModify("INSERT INTO users (username, limitby, balance, lifetimepaid, email, overcharge, description) VALUES (%s, %s, %s, %s, %s, %s, %s)" % \
-                                     (self.doQuote(self.userCharsetToDatabase(user.Name)), \
+                                     (self.doQuote(self.unicodeToDatabase(user.Name)), \
                                       self.doQuote(user.LimitBy or 'quota'), \
                                       self.doQuote(user.AccountBalance or 0.0), \
@@ -604,5 +604,5 @@
                                       self.doQuote(user.Email), \
                                       self.doQuote(user.OverCharge), \
-                                      self.doQuote(self.userCharsetToDatabase(user.Description))))
+                                      self.doQuote(self.unicodeToDatabase(user.Description))))
         if user.PaymentsBacklog :
             for (value, comment) in user.PaymentsBacklog :
@@ -618,7 +618,7 @@
             return oldentry
         self.doModify("INSERT INTO groups (groupname, limitby, description) VALUES (%s, %s, %s)" % \
-                              (self.doQuote(self.userCharsetToDatabase(group.Name)), \
+                              (self.doQuote(self.unicodeToDatabase(group.Name)), \
                                self.doQuote(group.LimitBy or "quota"), \
-                               self.doQuote(self.userCharsetToDatabase(group.Description))))
+                               self.doQuote(self.unicodeToDatabase(group.Description))))
         group.isDirty = False
         return None # the entry created doesn't need further modification
@@ -677,5 +677,5 @@
                               % (self.doQuote((printer.PassThrough and "t") or "f"), \
                                  self.doQuote(printer.MaxJobSize or 0), \
-                                 self.doQuote(self.userCharsetToDatabase(printer.Description)), \
+                                 self.doQuote(self.unicodeToDatabase(printer.Description)), \
                                  self.doQuote(printer.PricePerPage or 0.0), \
                                  self.doQuote(printer.PricePerJob or 0.0), \
@@ -690,5 +690,5 @@
                                   self.doQuote(user.Email), \
                                   self.doQuote(user.OverCharge), \
-                                  self.doQuote(self.userCharsetToDatabase(user.Description)), \
+                                  self.doQuote(self.unicodeToDatabase(user.Description)), \
                                   self.doQuote(user.ident)))
                                   
@@ -697,5 +697,5 @@
         self.doModify("UPDATE groups SET limitby=%s, description=%s WHERE id=%s" \
                                % (self.doQuote(group.LimitBy or 'quota'), \
-                                  self.doQuote(self.userCharsetToDatabase(group.Description)), \
+                                  self.doQuote(self.unicodeToDatabase(group.Description)), \
                                   self.doQuote(group.ident)))
         
@@ -717,5 +717,5 @@
                             % (self.doQuote(bcode.Balance or 0.0), \
                                self.doQuote(bcode.PageCounter or 0), \
-                               self.doQuote(self.userCharsetToDatabase(bcode.Description)), \
+                               self.doQuote(self.unicodeToDatabase(bcode.Description)), \
                                self.doQuote(bcode.ident)))
        
@@ -735,7 +735,7 @@
         """Adds a new payment to the payments history."""
         if user.ident is not None :
-            self.doModify("INSERT INTO payments (userid, amount, description) VALUES (%s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(amount), self.doQuote(self.userCharsetToDatabase(comment))))
+            self.doModify("INSERT INTO payments (userid, amount, description) VALUES (%s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(amount), self.doQuote(self.unicodeToDatabase(comment))))
         else :    
-            self.doModify("INSERT INTO payments (userid, amount, description) VALUES ((SELECT id FROM users WHERE username=%s), %s, %s)" % (self.doQuote(self.userCharsetToDatabase(user.Name)), self.doQuote(amount), self.doQuote(self.userCharsetToDatabase(comment))))
+            self.doModify("INSERT INTO payments (userid, amount, description) VALUES ((SELECT id FROM users WHERE username=%s), %s, %s)" % (self.doQuote(self.unicodeToDatabase(user.Name)), self.doQuote(amount), self.doQuote(self.unicodeToDatabase(comment))))
         
     def writeLastJobSize(self, lastjob, jobsize, jobprice) :        
@@ -748,8 +748,8 @@
             # For legal reasons, we want to hide the title, filename and options
             title = filename = options = "hidden"
-        filename = self.userCharsetToDatabase(filename)
-        title = self.userCharsetToDatabase(title)
-        options = self.userCharsetToDatabase(options)
-        jobbilling = self.userCharsetToDatabase(jobbilling)
+        filename = self.unicodeToDatabase(filename)
+        title = self.unicodeToDatabase(title)
+        options = self.unicodeToDatabase(options)
+        jobbilling = self.unicodeToDatabase(jobbilling)
         if (not self.disablehistory) or (not printer.LastJob.Exists) :
             if jobsize is not None :
@@ -814,7 +814,7 @@
             where.append("hostname=%s" % self.doQuote(hostname))
         if billingcode is not None :    
-            where.append("billingcode=%s" % self.doQuote(self.userCharsetToDatabase(billingcode)))
+            where.append("billingcode=%s" % self.doQuote(self.unicodeToDatabase(billingcode)))
         if jobid is not None :    
-            where.append("jobid=%s" % self.doQuote(jobid)) # TODO : jobid is text, so self.userCharsetToDatabase(jobid) but do all of them as well.
+            where.append("jobid=%s" % self.doQuote(jobid)) # TODO : jobid is text, so self.unicodeToDatabase(jobid) but do all of them as well.
         if start is not None :    
             where.append("jobdate>=%s" % self.doQuote(start))
Index: pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- pykota/trunk/pykota/storages/ldapstorage.py (revision 3288)
+++ pykota/trunk/pykota/storages/ldapstorage.py (revision 3291)
@@ -303,5 +303,5 @@
                 self.tool.printInfo("Object %s has no %s attribute !" % (dn, attribute), "error")
             else :
-                attrval = self.databaseToUserCharset(attrval)
+                attrval = self.databaseToUnicode(attrval)
                 if patterns :
                     if (not isinstance(patterns, type([]))) and (not isinstance(patterns, type(()))) :
@@ -318,5 +318,5 @@
         result = self.doSearch(ldapfilter, ["pykotaBillingCode"], base=self.info["billingcodebase"])
         if result :
-            return [self.databaseToUserCharset(bc) for bc in self.filterNames(result, "pykotaBillingCode", billingcode)]
+            return [self.databaseToUnicode(bc) for bc in self.filterNames(result, "pykotaBillingCode", billingcode)]
         else :    
             return []
@@ -351,5 +351,5 @@
     def getUserNbJobsFromHistory(self, user) :
         """Returns the number of jobs the user has in history."""
-        result = self.doSearch("(&(pykotaUserName=%s)(objectClass=pykotaJob))" % self.userCharsetToDatabase(user.Name), None, base=self.info["jobbase"])
+        result = self.doSearch("(&(pykotaUserName=%s)(objectClass=pykotaJob))" % self.unicodeToDatabase(user.Name), None, base=self.info["jobbase"])
         return len(result)
         
@@ -357,10 +357,10 @@
         """Extracts user information given its name."""
         user = StorageUser(self, username)
-        username = self.userCharsetToDatabase(username)
+        username = self.unicodeToDatabase(username)
         result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "description"], base=self.info["userbase"])
         if result :
             fields = result[0][1]
             user.ident = result[0][0]
-            user.Description = self.databaseToUserCharset(fields.get("description", [None])[0])
+            user.Description = self.databaseToUnicode(fields.get("description", [None])[0])
             user.Email = fields.get(self.info["usermail"], [None])[0]
             user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0]
@@ -395,5 +395,5 @@
                         description = ""
                     else :    
-                        description = self.databaseToUserCharset(base64.decodestring(description))
+                        description = self.databaseToUnicode(base64.decodestring(description))
                     if amount.endswith(" #") :    
                         amount = amount[:-2] # TODO : should be catched earlier, the bug is above I think
@@ -405,11 +405,11 @@
         """Extracts group information given its name."""
         group = StorageGroup(self, groupname)
-        groupname = self.userCharsetToDatabase(groupname)
+        groupname = self.unicodeToDatabase(groupname)
         result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % (groupname, self.info["grouprdn"], groupname), ["pykotaGroupName", "pykotaLimitBy", "description"], base=self.info["groupbase"])
         if result :
             fields = result[0][1]
             group.ident = result[0][0]
-            group.Name = fields.get("pykotaGroupName", [self.databaseToUserCharset(groupname)])[0] 
-            group.Description = self.databaseToUserCharset(fields.get("description", [None])[0])
+            group.Name = fields.get("pykotaGroupName", [self.databaseToUnicode(groupname)])[0] 
+            group.Description = self.databaseToUnicode(fields.get("description", [None])[0])
             group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0]
             group.AccountBalance = 0.0
@@ -425,5 +425,5 @@
         """Extracts printer information given its name : returns first matching printer."""
         printer = StoragePrinter(self, printername)
-        printername = self.userCharsetToDatabase(printername)
+        printername = self.unicodeToDatabase(printername)
         result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" \
                       % (printername, self.info["printerrdn"], printername), \
@@ -435,5 +435,5 @@
             fields = result[0][1]       # take only first matching printer, ignore the rest
             printer.ident = result[0][0]
-            printer.Name = fields.get("pykotaPrinterName", [self.databaseToUserCharset(printername)])[0] 
+            printer.Name = fields.get("pykotaPrinterName", [self.databaseToUnicode(printername)])[0] 
             printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0])
             printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0])
@@ -445,5 +445,5 @@
                 printer.PassThrough = 0
             printer.uniqueMember = fields.get("uniqueMember", [])
-            printer.Description = self.databaseToUserCharset(fields.get("description", [""])[0]) 
+            printer.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 
             printer.Exists = True
         return printer    
@@ -458,5 +458,5 @@
                 base = self.info["userquotabase"]
             result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaUserName=%s)(pykotaPrinterName=%s))" % \
-                                      (self.userCharsetToDatabase(user.Name), self.userCharsetToDatabase(printer.Name)), \
+                                      (self.unicodeToDatabase(user.Name), self.unicodeToDatabase(printer.Name)), \
                                       ["pykotaPageCounter", "pykotaLifePageCounter", "pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit", "pykotaWarnCount", "pykotaMaxJobSize"], \
                                       base=base)
@@ -503,5 +503,5 @@
                 base = self.info["groupquotabase"]
             result = self.doSearch("(&(objectClass=pykotaGroupPQuota)(pykotaGroupName=%s)(pykotaPrinterName=%s))" % \
-                                      (self.userCharsetToDatabase(group.Name), self.userCharsetToDatabase(printer.Name)), \
+                                      (self.unicodeToDatabase(group.Name), self.unicodeToDatabase(printer.Name)), \
                                       ["pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit", "pykotaMaxJobSize"], \
                                       base=base)
@@ -535,5 +535,5 @@
                 grouppquota.PageCounter = 0
                 grouppquota.LifePageCounter = 0
-                usernamesfilter = "".join(["(pykotaUserName=%s)" % self.userCharsetToDatabase(member.Name) for member in self.getGroupMembers(group)])
+                usernamesfilter = "".join(["(pykotaUserName=%s)" % self.unicodeToDatabase(member.Name) for member in self.getGroupMembers(group)])
                 if usernamesfilter :
                     usernamesfilter = "(|%s)" % usernamesfilter
@@ -543,5 +543,5 @@
                     base = self.info["userquotabase"]
                 result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaPrinterName=%s)%s)" % \
-                                          (self.userCharsetToDatabase(printer.Name), usernamesfilter), \
+                                          (self.unicodeToDatabase(printer.Name), usernamesfilter), \
                                           ["pykotaPageCounter", "pykotaLifePageCounter"], base=base)
                 if result :
@@ -555,5 +555,5 @@
         """Extracts a printer's last job information."""
         lastjob = StorageLastJob(self, printer)
-        pname = self.userCharsetToDatabase(printer.Name)
+        pname = self.unicodeToDatabase(printer.Name)
         result = self.doSearch("(&(objectClass=pykotaLastjob)(|(pykotaPrinterName=%s)(%s=%s)))" % \
                                   (pname, self.info["printerrdn"], pname), \
@@ -591,5 +591,5 @@
                 lastjob.ident = result[0][0]
                 lastjob.JobId = fields.get("pykotaJobId")[0]
-                lastjob.UserName = self.databaseToUserCharset(fields.get("pykotaUserName")[0])
+                lastjob.UserName = self.databaseToUnicode(fields.get("pykotaUserName")[0])
                 lastjob.PrinterPageCounter = int(fields.get("pykotaPrinterPageCounter", [0])[0])
                 try :
@@ -602,11 +602,11 @@
                     lastjob.JobPrice = None
                 lastjob.JobAction = fields.get("pykotaAction", [""])[0]
-                lastjob.JobFileName = self.databaseToUserCharset(fields.get("pykotaFileName", [""])[0]) 
-                lastjob.JobTitle = self.databaseToUserCharset(fields.get("pykotaTitle", [""])[0]) 
+                lastjob.JobFileName = self.databaseToUnicode(fields.get("pykotaFileName", [""])[0]) 
+                lastjob.JobTitle = self.databaseToUnicode(fields.get("pykotaTitle", [""])[0]) 
                 lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0])
-                lastjob.JobOptions = self.databaseToUserCharset(fields.get("pykotaOptions", [""])[0]) 
+                lastjob.JobOptions = self.databaseToUnicode(fields.get("pykotaOptions", [""])[0]) 
                 lastjob.JobHostName = fields.get("pykotaHostName", [""])[0]
                 lastjob.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0]
-                lastjob.JobBillingCode = self.databaseToUserCharset(fields.get("pykotaBillingCode", [None])[0])
+                lastjob.JobBillingCode = self.databaseToUnicode(fields.get("pykotaBillingCode", [None])[0])
                 lastjob.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0]
                 lastjob.JobPages = fields.get("pykotaPages", [""])[0]
@@ -630,5 +630,5 @@
         """Returns the group's members list."""
         groupmembers = []
-        gname = self.userCharsetToDatabase(group.Name)
+        gname = self.unicodeToDatabase(group.Name)
         result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % \
                                   (gname, self.info["grouprdn"], gname), \
@@ -637,5 +637,5 @@
         if result :
             for username in result[0][1].get(self.info["groupmembers"], []) :
-                groupmembers.append(self.getUser(self.databaseToUserCharset(username)))
+                groupmembers.append(self.getUser(self.databaseToUnicode(username)))
         return groupmembers        
         
@@ -643,5 +643,5 @@
         """Returns the user's groups list."""
         groups = []
-        uname = self.userCharsetToDatabase(user.Name)
+        uname = self.unicodeToDatabase(user.Name)
         result = self.doSearch("(&(objectClass=pykotaGroup)(%s=%s))" % \
                                   (self.info["groupmembers"], uname), \
@@ -650,5 +650,5 @@
         if result :
             for (groupid, fields) in result :
-                groupname = self.databaseToUserCharset((fields.get("pykotaGroupName", [None]) or fields.get(self.info["grouprdn"], [None]))[0])
+                groupname = self.databaseToUnicode((fields.get("pykotaGroupName", [None]) or fields.get(self.info["grouprdn"], [None]))[0])
                 group = self.getFromCache("GROUPS", groupname)
                 if group is None :
@@ -681,5 +681,5 @@
             for (printerid, fields) in result :
                 if printerid != printer.ident : # In case of integrity violation.
-                    parentprinter = self.getPrinter(self.databaseToUserCharset(fields.get("pykotaPrinterName")[0]))
+                    parentprinter = self.getPrinter(self.databaseToUnicode(fields.get("pykotaPrinterName")[0]))
                     if parentprinter.Exists :
                         pgroups.append(parentprinter)
@@ -703,5 +703,5 @@
                     patdict[p] = None
             for (printerid, fields) in result :
-                printername = self.databaseToUserCharset(fields.get("pykotaPrinterName", [""])[0] or fields.get(self.info["printerrdn"], [""])[0])
+                printername = self.databaseToUnicode(fields.get("pykotaPrinterName", [""])[0] or fields.get(self.info["printerrdn"], [""])[0])
                 if patdict.has_key(printername) or self.tool.matchString(printername, patterns) :
                     printer = StoragePrinter(self, printername)
@@ -716,5 +716,5 @@
                         printer.PassThrough = 0
                     printer.uniqueMember = fields.get("uniqueMember", [])
-                    printer.Description = self.databaseToUserCharset(fields.get("description", [""])[0]) 
+                    printer.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 
                     printer.Exists = True
                     printers.append(printer)
@@ -739,5 +739,5 @@
                     patdict[p] = None
             for (userid, fields) in result :
-                username = self.databaseToUserCharset(fields.get("pykotaUserName", [""])[0] or fields.get(self.info["userrdn"], [""])[0])
+                username = self.databaseToUnicode(fields.get("pykotaUserName", [""])[0] or fields.get(self.info["userrdn"], [""])[0])
                 if patdict.has_key(username) or self.tool.matchString(username, patterns) :
                     user = StorageUser(self, username)
@@ -745,6 +745,6 @@
                     user.Email = fields.get(self.info["usermail"], [None])[0]
                     user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0]
-                    user.Description = self.databaseToUserCharset(fields.get("description", [""])[0]) 
-                    uname = self.userCharsetToDatabase(username)
+                    user.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 
+                    uname = self.unicodeToDatabase(username)
                     result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % \
                                               (uname, self.info["balancerdn"], uname), \
@@ -780,5 +780,5 @@
                                 description = ""
                             else :    
-                                description = self.databaseToUserCharset(base64.decodestring(description))
+                                description = self.databaseToUnicode(base64.decodestring(description))
                             if amount.endswith(" #") :    
                                 amount = amount[:-2] # TODO : should be catched earlier, the bug is above I think
@@ -806,11 +806,11 @@
                     patdict[p] = None
             for (groupid, fields) in result :
-                groupname = self.databaseToUserCharset(fields.get("pykotaGroupName", [""])[0] or fields.get(self.info["grouprdn"], [""])[0])
+                groupname = self.databaseToUnicode(fields.get("pykotaGroupName", [""])[0] or fields.get(self.info["grouprdn"], [""])[0])
                 if patdict.has_key(groupname) or self.tool.matchString(groupname, patterns) :
                     group = StorageGroup(self, groupname)
                     group.ident = groupid
-                    group.Name = fields.get("pykotaGroupName", [self.databaseToUserCharset(groupname)])[0] 
+                    group.Name = fields.get("pykotaGroupName", [self.databaseToUnicode(groupname)])[0] 
                     group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0]
-                    group.Description = self.databaseToUserCharset(fields.get("description", [""])[0]) 
+                    group.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 
                     group.AccountBalance = 0.0
                     group.LifeTimePaid = 0.0
@@ -827,6 +827,6 @@
         """Returns the list of users who uses a given printer, along with their quotas."""
         usersandquotas = []
-        pname = self.userCharsetToDatabase(printer.Name)
-        names = [self.userCharsetToDatabase(n) for n in names]
+        pname = self.unicodeToDatabase(printer.Name)
+        names = [self.unicodeToDatabase(n) for n in names]
         if self.info["userquotabase"].lower() == "user" :
             base = self.info["userbase"]
@@ -839,5 +839,5 @@
         if result :
             for (userquotaid, fields) in result :
-                user = self.getUser(self.databaseToUserCharset(fields.get("pykotaUserName")[0]))
+                user = self.getUser(self.databaseToUnicode(fields.get("pykotaUserName")[0]))
                 userpquota = StorageUserPQuota(self, user, printer)
                 userpquota.ident = userquotaid
@@ -872,6 +872,6 @@
         """Returns the list of groups which uses a given printer, along with their quotas."""
         groupsandquotas = []
-        pname = self.userCharsetToDatabase(printer.Name)
-        names = [self.userCharsetToDatabase(n) for n in names]
+        pname = self.unicodeToDatabase(printer.Name)
+        names = [self.unicodeToDatabase(n) for n in names]
         if self.info["groupquotabase"].lower() == "group" :
             base = self.info["groupbase"]
@@ -884,5 +884,5 @@
         if result :
             for (groupquotaid, fields) in result :
-                group = self.getGroup(self.databaseToUserCharset(fields.get("pykotaGroupName")[0]))
+                group = self.getGroup(self.databaseToUnicode(fields.get("pykotaGroupName")[0]))
                 grouppquota = self.getGroupPQuota(group, printer)
                 groupsandquotas.append((group, grouppquota))
@@ -895,5 +895,5 @@
         if oldentry.Exists :
             return oldentry # we return the existing entry
-        printername = self.userCharsetToDatabase(printer.Name)
+        printername = self.unicodeToDatabase(printer.Name)
         fields = { self.info["printerrdn"] : printername,
                    "objectClass" : ["pykotaObject", "pykotaPrinter"],
@@ -902,5 +902,5 @@
                    "pykotaPassThrough" : (printer.PassThrough and "t") or "f",
                    "pykotaMaxJobSize" : str(printer.MaxJobSize or 0),
-                   "description" : self.userCharsetToDatabase(printer.Description or ""),
+                   "description" : self.unicodeToDatabase(printer.Description or ""),
                    "pykotaPricePerPage" : str(printer.PricePerPage or 0.0),
                    "pykotaPricePerJob" : str(printer.PricePerJob or 0.0),
@@ -916,9 +916,9 @@
         if oldentry.Exists :
             return oldentry # we return the existing entry
-        uname = self.userCharsetToDatabase(user.Name)
+        uname = self.unicodeToDatabase(user.Name)
         newfields = {
                        "pykotaUserName" : uname,
                        "pykotaLimitBy" : (user.LimitBy or "quota"),
-                       "description" : self.userCharsetToDatabase(user.Description or ""),
+                       "description" : self.unicodeToDatabase(user.Description or ""),
                        self.info["usermail"] : user.Email or "",
                     }   
@@ -991,9 +991,9 @@
         if oldentry.Exists :
             return oldentry # we return the existing entry
-        gname = self.userCharsetToDatabase(group.Name)
+        gname = self.unicodeToDatabase(group.Name)
         newfields = { 
                       "pykotaGroupName" : gname,
                       "pykotaLimitBy" : (group.LimitBy or "quota"),
-                      "description" : self.userCharsetToDatabase(group.Description or "")
+                      "description" : self.unicodeToDatabase(group.Description or "")
                     } 
         mustadd = 1
@@ -1040,5 +1040,5 @@
                 if not fields.has_key(self.info["groupmembers"]) :
                     fields[self.info["groupmembers"]] = []
-                fields[self.info["groupmembers"]].append(self.userCharsetToDatabase(user.Name))
+                fields[self.info["groupmembers"]].append(self.unicodeToDatabase(user.Name))
                 self.doModify(group.ident, fields)
                 group.Members.append(user)
@@ -1053,5 +1053,5 @@
                     fields[self.info["groupmembers"]] = []
                 try :    
-                    fields[self.info["groupmembers"]].remove(self.userCharsetToDatabase(user.Name))
+                    fields[self.info["groupmembers"]].remove(self.unicodeToDatabase(user.Name))
                 except ValueError :
                     pass # TODO : Strange, shouldn't it be there ?
@@ -1067,6 +1067,6 @@
             return oldentry # we return the existing entry
         uuid = self.genUUID()
-        uname = self.userCharsetToDatabase(upq.User.Name)
-        pname = self.userCharsetToDatabase(upq.Printer.Name)
+        uname = self.unicodeToDatabase(upq.User.Name)
+        pname = self.unicodeToDatabase(upq.Printer.Name)
         fields = { "cn" : uuid,
                    "objectClass" : ["pykotaObject", "pykotaUserPQuota"],
@@ -1095,6 +1095,6 @@
             return oldentry # we return the existing entry
         uuid = self.genUUID()
-        gname = self.userCharsetToDatabase(gpq.Group.Name)
-        pname = self.userCharsetToDatabase(gpq.Printer.Name)
+        gname = self.unicodeToDatabase(gpq.Group.Name)
+        pname = self.unicodeToDatabase(gpq.Printer.Name)
         fields = { "cn" : uuid,
                    "objectClass" : ["pykotaObject", "pykotaGroupPQuota"],
@@ -1116,5 +1116,5 @@
                    "pykotaPassThrough" : (printer.PassThrough and "t") or "f",
                    "pykotaMaxJobSize" : str(printer.MaxJobSize or 0),
-                   "description" : self.userCharsetToDatabase(printer.Description or ""),
+                   "description" : self.unicodeToDatabase(printer.Description or ""),
                    "pykotaPricePerPage" : str(printer.PricePerPage or 0.0),
                    "pykotaPricePerJob" : str(printer.PricePerJob or 0.0),
@@ -1126,5 +1126,5 @@
         newfields = {
                        "pykotaLimitBy" : (user.LimitBy or "quota"),
-                       "description" : self.userCharsetToDatabase(user.Description or ""), 
+                       "description" : self.unicodeToDatabase(user.Description or ""), 
                        self.info["usermail"] : user.Email or "",
                     }   
@@ -1141,5 +1141,5 @@
         newfields = {
                        "pykotaLimitBy" : (group.LimitBy or "quota"),
-                       "description" : self.userCharsetToDatabase(group.Description or ""), 
+                       "description" : self.unicodeToDatabase(group.Description or ""), 
                     }   
         self.doModify(group.ident, newfields)
@@ -1178,6 +1178,6 @@
         payments = []
         for payment in user.Payments :
-            payments.append("%s # %s # %s" % (payment[0], str(payment[1]), base64.encodestring(self.userCharsetToDatabase(payment[2])).strip()))
-        payments.append("%s # %s # %s" % (str(DateTime.now()), str(amount), base64.encodestring(self.userCharsetToDatabase(comment)).strip()))
+            payments.append("%s # %s # %s" % (payment[0], str(payment[1]), base64.encodestring(self.unicodeToDatabase(payment[2])).strip()))
+        payments.append("%s # %s # %s" % (str(DateTime.now()), str(amount), base64.encodestring(self.unicodeToDatabase(comment)).strip()))
         fields = {
                    "pykotaPayments" : payments,
@@ -1195,6 +1195,6 @@
     def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None, jobmd5sum=None, jobpages=None, jobbilling=None, precomputedsize=None, precomputedprice=None) :
         """Adds a job in a printer's history."""
-        uname = self.userCharsetToDatabase(user.Name)
-        pname = self.userCharsetToDatabase(printer.Name)
+        uname = self.unicodeToDatabase(user.Name)
+        pname = self.unicodeToDatabase(printer.Name)
         if (not self.disablehistory) or (not printer.LastJob.Exists) :
             uuid = self.genUUID()
@@ -1214,13 +1214,13 @@
                    "pykotaPrinterPageCounter" : str(pagecounter),
                    "pykotaAction" : action,
-                   "pykotaFileName" : ((filename is None) and "None") or self.userCharsetToDatabase(filename), 
-                   "pykotaTitle" : ((title is None) and "None") or self.userCharsetToDatabase(title), 
+                   "pykotaFileName" : ((filename is None) and "None") or self.unicodeToDatabase(filename), 
+                   "pykotaTitle" : ((title is None) and "None") or self.unicodeToDatabase(title), 
                    "pykotaCopies" : str(copies), 
-                   "pykotaOptions" : ((options is None) and "None") or self.userCharsetToDatabase(options), 
+                   "pykotaOptions" : ((options is None) and "None") or self.unicodeToDatabase(options), 
                    "pykotaHostName" : str(clienthost), 
                    "pykotaJobSizeBytes" : str(jobsizebytes),
                    "pykotaMD5Sum" : str(jobmd5sum),
                    "pykotaPages" : jobpages,            # don't add this attribute if it is not set, so no string conversion
-                   "pykotaBillingCode" : self.userCharsetToDatabase(jobbilling), # don't add this attribute if it is not set, so no string conversion
+                   "pykotaBillingCode" : self.unicodeToDatabase(jobbilling), # don't add this attribute if it is not set, so no string conversion
                    "pykotaPrecomputedJobSize" : str(precomputedsize),
                    "pykotaPrecomputedJobPrice" : str(precomputedprice),
@@ -1314,13 +1314,13 @@
         where = []
         if user is not None :
-            where.append("(pykotaUserName=%s)" % self.userCharsetToDatabase(user.Name))
+            where.append("(pykotaUserName=%s)" % self.unicodeToDatabase(user.Name))
         if printer is not None :
-            where.append("(pykotaPrinterName=%s)" % self.userCharsetToDatabase(printer.Name))
+            where.append("(pykotaPrinterName=%s)" % self.unicodeToDatabase(printer.Name))
         if hostname is not None :
             where.append("(pykotaHostName=%s)" % hostname)
         if billingcode is not None :
-            where.append("(pykotaBillingCode=%s)" % self.userCharsetToDatabase(billingcode))
+            where.append("(pykotaBillingCode=%s)" % self.unicodeToDatabase(billingcode))
         if jobid is not None :
-            where.append("(pykotaJobId=%s)" % jobid) # TODO : jobid is text, so self.userCharsetToDatabase(jobid) but do all of them as well.
+            where.append("(pykotaJobId=%s)" % jobid) # TODO : jobid is text, so self.unicodeToDatabase(jobid) but do all of them as well.
         if where :    
             where = "(&%s)" % "".join([precond] + where)
@@ -1363,11 +1363,11 @@
                     job.JobPrice = None
                 job.JobAction = fields.get("pykotaAction", [""])[0]
-                job.JobFileName = self.databaseToUserCharset(fields.get("pykotaFileName", [""])[0]) 
-                job.JobTitle = self.databaseToUserCharset(fields.get("pykotaTitle", [""])[0]) 
+                job.JobFileName = self.databaseToUnicode(fields.get("pykotaFileName", [""])[0]) 
+                job.JobTitle = self.databaseToUnicode(fields.get("pykotaTitle", [""])[0]) 
                 job.JobCopies = int(fields.get("pykotaCopies", [0])[0])
-                job.JobOptions = self.databaseToUserCharset(fields.get("pykotaOptions", [""])[0]) 
+                job.JobOptions = self.databaseToUnicode(fields.get("pykotaOptions", [""])[0]) 
                 job.JobHostName = fields.get("pykotaHostName", [""])[0]
                 job.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0]
-                job.JobBillingCode = self.databaseToUserCharset(fields.get("pykotaBillingCode", [None])[0])
+                job.JobBillingCode = self.databaseToUnicode(fields.get("pykotaBillingCode", [None])[0])
                 job.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0]
                 job.JobPages = fields.get("pykotaPages", [""])[0]
@@ -1389,6 +1389,6 @@
                    ((end is None) and (job.JobDate >= start)) or \
                    ((job.JobDate >= start) and (job.JobDate <= end)) :
-                    job.UserName = self.databaseToUserCharset(fields.get("pykotaUserName")[0])
-                    job.PrinterName = self.databaseToUserCharset(fields.get("pykotaPrinterName")[0])
+                    job.UserName = self.databaseToUnicode(fields.get("pykotaUserName")[0])
+                    job.PrinterName = self.databaseToUnicode(fields.get("pykotaPrinterName")[0])
                     job.Exists = True
                     jobs.append(job)
@@ -1400,5 +1400,5 @@
     def deleteUser(self, user) :    
         """Completely deletes an user from the Quota Storage."""
-        uname = self.userCharsetToDatabase(user.Name)
+        uname = self.unicodeToDatabase(user.Name)
         todelete = []    
         result = self.doSearch("(&(objectClass=pykotaJob)(pykotaUserName=%s))" % uname, base=self.info["jobbase"])
@@ -1418,5 +1418,5 @@
             # if last job of current printer was printed by the user
             # to delete, we also need to delete the printer's last job entry.
-            printer = self.getPrinter(self.databaseToUserCharset(fields["pykotaPrinterName"][0]))
+            printer = self.getPrinter(self.databaseToUnicode(fields["pykotaPrinterName"][0]))
             if printer.LastJob.UserName == user.Name :
                 todelete.append(printer.LastJob.lastjobident)
@@ -1453,5 +1453,5 @@
     def deleteGroup(self, group) :    
         """Completely deletes a group from the Quota Storage."""
-        gname = self.userCharsetToDatabase(group.Name)
+        gname = self.unicodeToDatabase(group.Name)
         if self.info["groupquotabase"].lower() == "group" :
             base = self.info["groupbase"]
@@ -1524,6 +1524,6 @@
     def deleteUserPQuota(self, upquota) :    
         """Completely deletes an user print quota entry from the database."""
-        uname = self.userCharsetToDatabase(upquota.User.Name)
-        pname = self.userCharsetToDatabase(upquota.Printer.Name)
+        uname = self.unicodeToDatabase(upquota.User.Name)
+        pname = self.unicodeToDatabase(upquota.Printer.Name)
         result = self.doSearch("(&(objectClass=pykotaJob)(pykotaUserName=%s)(pykotaPrinterName=%s))" \
                                    % (uname, pname), \
@@ -1541,5 +1541,5 @@
     def deletePrinter(self, printer) :    
         """Completely deletes a printer from the Quota Storage."""
-        pname = self.userCharsetToDatabase(printer.Name)
+        pname = self.unicodeToDatabase(printer.Name)
         result = self.doSearch("(&(objectClass=pykotaLastJob)(pykotaPrinterName=%s))" % pname, base=self.info["lastjobbase"])
         for (ident, fields) in result :
@@ -1764,5 +1764,5 @@
         """Extracts billing code information given its label : returns first matching billing code."""
         code = StorageBillingCode(self, label)
-        ulabel = self.userCharsetToDatabase(label)
+        ulabel = self.unicodeToDatabase(label)
         result = self.doSearch("(&(objectClass=pykotaBilling)(pykotaBillingCode=%s))" % \
                                   ulabel, \
@@ -1772,8 +1772,8 @@
             fields = result[0][1]       # take only first matching code, ignore the rest
             code.ident = result[0][0]
-            code.BillingCode = self.databaseToUserCharset(fields.get("pykotaBillingCode", [ulabel])[0])
+            code.BillingCode = self.databaseToUnicode(fields.get("pykotaBillingCode", [ulabel])[0])
             code.PageCounter = int(fields.get("pykotaPageCounter", [0])[0])
             code.Balance = float(fields.get("pykotaBalance", [0.0])[0])
-            code.Description = self.databaseToUserCharset(fields.get("description", [""])[0]) 
+            code.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 
             code.Exists = True
         return code    
@@ -1788,8 +1788,8 @@
         fields = { "objectClass" : ["pykotaObject", "pykotaBilling"],
                    "cn" : uuid,
-                   "pykotaBillingCode" : self.userCharsetToDatabase(bcode.BillingCode),
+                   "pykotaBillingCode" : self.unicodeToDatabase(bcode.BillingCode),
                    "pykotaPageCounter" : str(bcode.PageCounter or 0),
                    "pykotaBalance" : str(bcode.Balance or 0.0),
-                   "description" : self.userCharsetToDatabase(bcode.Description or ""), 
+                   "description" : self.unicodeToDatabase(bcode.Description or ""), 
                  } 
         self.doAdd(dn, fields)
@@ -1800,5 +1800,5 @@
         """Sets the new description for a billing code."""
         fields = {
-                   "description" : self.userCharsetToDatabase(bcode.Description or ""), 
+                   "description" : self.unicodeToDatabase(bcode.Description or ""), 
                    "pykotaPageCounter" : str(bcode.PageCounter or 0),
                    "pykotaBalance" : str(bcode.Balance or 0.0),
@@ -1822,5 +1822,5 @@
                     patdict[p] = None
             for (codeid, fields) in result :
-                codename = self.databaseToUserCharset(fields.get("pykotaBillingCode", [""])[0])
+                codename = self.databaseToUnicode(fields.get("pykotaBillingCode", [""])[0])
                 if patdict.has_key(codename) or self.tool.matchString(codename, patterns) :
                     code = StorageBillingCode(self, codename)
@@ -1828,5 +1828,5 @@
                     code.PageCounter = int(fields.get("pykotaPageCounter", [0])[0])
                     code.Balance = float(fields.get("pykotaBalance", [0.0])[0])
-                    code.Description = self.databaseToUserCharset(fields.get("description", [""])[0]) 
+                    code.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 
                     code.Exists = True
                     codes.append(code)
