def unicoder(p, force=False):
 if isinstance(p, unicode):
  return p
 if isinstance(p, str):
  if (gUTF or force):
   try:
    return p.decode('utf-8')
   except:
    return p.decode(codepage, 'replace')
  return p.decode(codepage, 'replace')
 else:
  return unicode(str(p))

def unicoder ( p , force = False ) : if isinstance ( p , unicode ) : return p if isinstance ( p , str ) : if ( gUTF or force ) : try : return p . decode ( 'utf-8' ) except : return p . decode ( codepage , 'replace' ) return p . decode ( codepage , 'replace' ) else : return unicode ( str ( p ) )
make sure a unicode string is returned when force is true .