def UTF8ToUTF16BE(instr, setbom=True):
 outstr = ''.encode()
 if setbom:
  outstr += '\xfe\xff'.encode('latin1')
 if (not isinstance(instr, unicode)):
  instr = instr.decode('UTF-8')
 outstr += instr.encode('UTF-16BE')
 if PY3K:
  outstr = outstr.decode('latin1')
 return outstr

def UTF8ToUTF16BE ( instr , setbom = True ) : outstr = '' . encode ( ) if setbom : outstr += '\xfe\xff' . encode ( 'latin1' ) if ( not isinstance ( instr , unicode ) ) : instr = instr . decode ( 'UTF-8' ) outstr += instr . encode ( 'UTF-16BE' ) if PY3K : outstr = outstr . decode ( 'latin1' ) return outstr
converts utf-8 strings to utf16-be .