def hexescape(char):
 hex_repr = hex(ord(char))[2:].upper()
 if (len(hex_repr) == 1):
  hex_repr = ('0%s' % hex_repr)
 return ('%' + hex_repr)

def hexescape ( char ) : hex_repr = hex ( ord ( char ) ) [ 2 : ] . upper ( ) if ( len ( hex_repr ) == 1 ) : hex_repr = ( '0%s' % hex_repr ) return ( '%' + hex_repr )
escape char as rfc 2396 specifies .