def detectencoding_unicode(input, final=False):
 prefix = '@charset "'
 if input.startswith(prefix):
  pos = input.find('"', len(prefix))
  if (pos >= 0):
   return (input[len(prefix):pos], True)
 elif (final or (not prefix.startswith(input))):
  return ('utf-8', False)
 return (None, False)

def detectencoding_unicode ( input , final = False ) : prefix = '@charset "' if input . startswith ( prefix ) : pos = input . find ( '"' , len ( prefix ) ) if ( pos >= 0 ) : return ( input [ len ( prefix ) : pos ] , True ) elif ( final or ( not prefix . startswith ( input ) ) ) : return ( 'utf-8' , False ) return ( None , False )
detect the encoding of the unicode string input .