Changeset 2804 for pykota/trunk/pykota
- Timestamp:
- 03/25/06 22:22:07 (18 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storage.py
r2801 r2804 646 646 def databaseToUserCharset(self, text) : 647 647 """Converts from database format (UTF-8) to user's charset.""" 648 if text is not None : 649 try : 650 return unicode(text, "UTF-8").encode(self.tool.getCharset()) 651 except UnicodeError : 652 try : 653 # Incorrect locale settings ? 654 return unicode(text, "UTF-8").encode("ISO-8859-15") 655 except UnicodeError : 656 pass 657 return text 648 return self.tool.UTF8ToUserCharset(text) 658 649 659 650 def userCharsetToDatabase(self, text) : 660 651 """Converts from user's charset to database format (UTF-8).""" 661 if text is not None : 662 try : 663 return unicode(text, self.tool.getCharset()).encode("UTF-8") 664 except UnicodeError : 665 try : 666 # Incorrect locale settings ? 667 return unicode(text, "ISO-8859-15").encode("UTF-8") 668 except UnicodeError : 669 pass 670 return text 652 return self.tool.userCharsetToUTF8(text) 671 653 672 654 def cleanDates(self, startdate, enddate) : -
pykota/trunk/pykota/tool.py
r2795 r2804 236 236 """Returns the charset in use.""" 237 237 return self.charset 238 239 def UTF8ToUserCharset(self, text) : 240 """Converts from UTF-8 to user's charset.""" 241 if text is not None : 242 try : 243 return unicode(text, "UTF-8").encode(self.charset) 244 except UnicodeError : 245 try : 246 # Incorrect locale settings ? 247 return unicode(text, "UTF-8").encode("ISO-8859-15") 248 except UnicodeError : 249 pass 250 return text 251 252 def userCharsetToUTF8(self, text) : 253 """Converts from user's charset to UTF-8.""" 254 if text is not None : 255 try : 256 return unicode(text, self.charset).encode("UTF-8") 257 except UnicodeError : 258 try : 259 # Incorrect locale settings ? 260 return unicode(text, "ISO-8859-15").encode("UTF-8") 261 except UnicodeError : 262 pass 263 return text 238 264 239 265 def display(self, message) :