I am migrating a software product ,eventually I come to this problem.
s = '–' # https://www.fileformat.info/info/unicode/char/0096/index.htm
in python2
s.encode('iso8859_15').decode('iso8859_15') # u'-'
s.encode('utf-8').decode('iso8859_15') # u'-'
in python3
s.encode('iso8859_15').decode('iso8859_15')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python37\lib\encodings\iso8859_15.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode character '\u2013' in position 0: character maps to <undefined>
s.encode('utf-8').decode('iso8859_15') # 'â\x80\x93'
Please somebody explain , Why is that so and what is the solution for this.
Thanks in advance
I tried replacing this character with '-'(hyphen) but automation test cases failed, and modification of automation test cases is prohibited.