def decode_text(s):
 if s.startswith('\xfe\xff'):
  return unicode(s[2:], 'utf-16be', 'ignore')
 else:
  return ''.join((PDFDocEncoding[ord(c)] for c in s))

def decode_text ( s ) : if s . startswith ( '\xfe\xff' ) : return unicode ( s [ 2 : ] , 'utf-16be' , 'ignore' ) else : return '' . join ( ( PDFDocEncoding [ ord ( c ) ] for c in s ) )
decodes a pdfdocencoding string to unicode .