root/tags/release-0.6.2/lib/enc.py

Revision 1, 1.0 kB (checked in by mjoc, 2 years ago)

Initial import.

Line 
1 #
2 # OpenDict
3 # Copyright (c) 2005 Martynas Jocius <mjoc at akl.lt>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your opinion) any later version.
9 #
10 # This program is distributed in the hope that will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MECHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more detals.
14 #
15 # You shoud have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307 USA
19 #
20
21 """
22 Character encodings
23 """
24
25 import wx
26
27 if wx.USE_UNICODE:
28     toWX = fromWX = lambda s: s
29 else:
30     import locale
31     localeCharset = locale.getpreferredencoding()
32    
33     def toWX(s):
34         return s.encode(localeCharset, 'replace')
35
36     def fromWX(s):
37         return unicode(s, localeCharset)
38
Note: See TracBrowser for help on using the browser.