Motivation:
s = 诶
This is not an ASCII character, and we need to throw an error saying something like 'The string 诶 cannot be encoded using the encoding ASCII
But if we do something like,
raise UnicodeEncodeError('The string %s cannot be encoded using the encoding
%s',%(s, encoding))
The above would reraise the error. but if we just do without specifying any encoding:
print(s)
诶
I guess this is because it just dumps the bytes to string.
Also something like this would raise error:
print ('{}'.format(str(s)))
and the below gives the unicode conversion:
print('%s' ,%repr(s))
u'\u8bf6'
is there a way to get the text which was the original text in the Error output.