#!/usr/bin/env python
#coding=utf-8
import os
import codecs
import locale
import types
#def GetCurrDir(): return os.path.dirname("cndevOE.exe")
try:
defaultencoding = locale.getdefaultlocale()[1]
except:
defaultencoding = None
if not defaultencoding:
defaultencoding = 'utf-8'
try:
codecs.lookup(defaultencoding)
except:
defaultencoding = 'utf-8'
try:
defaultfilesystemencoding = sys.getfilesystemencoding()
except:
defaultfilesystemencoding = None
if not defaultfilesystemencoding:
defaultfilesystemencoding = 'ascii'
try:
codecs.lookup(defaultfilesystemencoding)
except:
defaultfilesystemencoding = 'ascii'
def GetCurrDir():
path = os.path.dirname(__file__)
if os.path.isfile(path):
path = os.path.dirname(os.path.abspath(path))
#print decode_string(path)
return decode_string(path)
#return os.path.dirname("cndevOE.exe")
def GetTransforSymbol():
return {"<":"<",">":">",""":'"',"(":"(",")":")"," ":" ","@":"@","&":"&"}
def unicode_path(path, encoding=defaultfilesystemencoding):
"""convert path to unicode
"""
return decode_string(path, encoding)
def (path, encoding=defaultfilesystemencoding):
return encode_string(path, encoding)
def decode_string(string, encoding=None):
"""convert string to unicode
If the second parameter encoding is omit, the default locale will be used.
"""
if not encoding:
encoding = defaultencoding
if not isinstance(string, types.UnicodeType):
return unicode(string, encoding)
else:
return string
unicode_string = decode_string
def encode_string(string, encoding=None):
"""convert unicode to string
If the second parameter encoding is omit, the default locale will be used.
"""
if not encoding:
encoding = defaultencoding
if isinstance(string, types.UnicodeType):
return string.encode(encoding)
else:
return string
机器人,
这首歌学会了没有?
我们的目标是->没有蛀牙!