def UnicodeFromCodePage(string):
 codepage = ctypes.windll.kernel32.GetOEMCP()
 try:
  return string.decode(('cp%s' % codepage))
 except UnicodeError:
  try:
   return string.decode('utf16', 'ignore')
  except UnicodeError:
   return string.decode('utf8', 'ignore')

def UnicodeFromCodePage ( string ) : codepage = ctypes . windll . kernel32 . GetOEMCP ( ) try : return string . decode ( ( 'cp%s' % codepage ) ) except UnicodeError : try : return string . decode ( 'utf16' , 'ignore' ) except UnicodeError : return string . decode ( 'utf8' , 'ignore' )
attempt to coerce string into a unicode object .