encode decode python c3 a2 5cx80 5cx99

Solutions on MaxInterview for encode decode python c3 a2 5cx80 5cx99 by the best coders in the world

showing results for - "encode decode python c3 a2 5cx80 5cx99"
Noha
23 Apr 2018
1LATIN_1_CHARS = (
2    ('\xe2\x80\x99', "'"),
3    ('\xc3\xa9', 'e'),
4    ('\xe2\x80\x90', '-'),
5    ('\xe2\x80\x91', '-'),
6    ('\xe2\x80\x92', '-'),
7    ('\xe2\x80\x93', '-'),
8    ('\xe2\x80\x94', '-'),
9    ('\xe2\x80\x94', '-'),
10    ('\xe2\x80\x98', "'"),
11    ('\xe2\x80\x9b', "'"),
12    ('\xe2\x80\x9c', '"'),
13    ('\xe2\x80\x9c', '"'),
14    ('\xe2\x80\x9d', '"'),
15    ('\xe2\x80\x9e', '"'),
16    ('\xe2\x80\x9f', '"'),
17    ('\xe2\x80\xa6', '...'),
18    ('\xe2\x80\xb2', "'"),
19    ('\xe2\x80\xb3', "'"),
20    ('\xe2\x80\xb4', "'"),
21    ('\xe2\x80\xb5', "'"),
22    ('\xe2\x80\xb6', "'"),
23    ('\xe2\x80\xb7', "'"),
24    ('\xe2\x81\xba', "+"),
25    ('\xe2\x81\xbb', "-"),
26    ('\xe2\x81\xbc', "="),
27    ('\xe2\x81\xbd', "("),
28    ('\xe2\x81\xbe', ")")
29)
30
31
32def clean_latin1(data):
33    try:
34        return data.encode('utf-8')
35    except UnicodeDecodeError:
36        data = data.decode('iso-8859-1')
37        for _hex, _char in LATIN_1_CHARS:
38            data = data.replace(_hex, _char)
39        return data.encode('utf8')
40
41
similar questions
queries leading to this page
encode decode python c3 a2 5cx80 5cx99