unicode improvements
This commit is contained in:
parent
d0b8fdecba
commit
792a335a35
3 changed files with 32 additions and 5 deletions
4
buildnum
4
buildnum
|
@ -1,4 +0,0 @@
|
||||||
(S'1.0.0-build'
|
|
||||||
p1
|
|
||||||
I10
|
|
||||||
t.
|
|
|
@ -6,3 +6,34 @@ Core modules from Cecil's library
|
||||||
__all__ = ["objproxy", "config"]
|
__all__ = ["objproxy", "config"]
|
||||||
|
|
||||||
import objproxy, config
|
import objproxy, config
|
||||||
|
|
||||||
|
def ascii(s):
|
||||||
|
if isinstance(s, unicode):
|
||||||
|
return s.encode(b'ascii')
|
||||||
|
else:
|
||||||
|
return str(s)
|
||||||
|
|
||||||
|
def utf8(s):
|
||||||
|
if isinstance(s, unicode):
|
||||||
|
return s.encode(b'utf-8')
|
||||||
|
else:
|
||||||
|
return str(s)
|
||||||
|
|
||||||
|
def from_ascii(s):
|
||||||
|
if isinstance(s, unicode):
|
||||||
|
return s
|
||||||
|
else:
|
||||||
|
return s.decode(b'ascii')
|
||||||
|
|
||||||
|
def from_latin1(s):
|
||||||
|
if isinstance(s, unicode):
|
||||||
|
return s
|
||||||
|
else:
|
||||||
|
return s.decode(b'latin-1')
|
||||||
|
|
||||||
|
def from_utf8(s):
|
||||||
|
if isinstance(s, unicode):
|
||||||
|
return s
|
||||||
|
else:
|
||||||
|
return s.decode(b'utf-8')
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ class inifile(dict):
|
||||||
|
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if type(key) != str:
|
if not isinstance(key, basestring):
|
||||||
raise TypeError, "Ini files can only contain string keys"
|
raise TypeError, "Ini files can only contain string keys"
|
||||||
|
|
||||||
if self.cur_section != None:
|
if self.cur_section != None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue