ValueError: string argument should contain only ASCII characters
See original GitHub issueHi
I just tried to convert the vcf created with MyPhoneExplorer to version 3. Unfortunately it does not work:
python3 vcard2to3.py vcard2.vcf Traceback (most recent call last): File "/home/pi/kontakte_tmp/vcard2to3/vcard2to3.py", line 250, in <module> main(sys.argv[1:]) File "/home/pi/kontakte_tmp/vcard2to3/vcard2to3.py", line 237, in main line = decoder.decode(line) File "/home/pi/kontakte_tmp/vcard2to3/vcard2to3.py", line 115, in decode decoded_line = quopri.decodestring(line).decode(self.encoding) File "/usr/lib/python3.9/quopri.py", line 162, in decodestring return a2b_qp(s, header=header) ValueError: string argument should contain only ASCII characters
Any idea how to solve this? Thanks! BR, Hugo
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
python - Check that a string contains only ASCII characters?
Now you can catch the "UnicodeDecodeError" to determine that the string did not contain just the ASCII characters. try: 'H€llø'. encode('utf-8' ...
Read more >string argument should contain only ASCII characters` when ...
I have ADE installed on the same computer as Calibre with DeDRM 10.0.3. ADE is authorized with a computer key that was automatically...
Read more >How to check if a string contains all ASCII characters in Python
In this shot, we are going to use the isascii() function in Python to check whether a string contains all ASCII characters. The...
Read more >Encoding and Decoding Strings (in Python 3.x)
The Python 3. SyntaxError: bytes can only contain ASCII literal characters. Now to see how bytes objects relate to strings, let's first look...
Read more >binascii — Convert between binary and ASCII — Python 3.11 ...
The binascii module contains a number of methods to convert between binary and ... a2b_* functions accept Unicode strings containing only ASCII characters....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the feedback and the sample file. Your file contains
öüß
in the quoted printable data (e.g. line 88). These are not valid characters, since in quoted printable representation only 7-bit ascii characters are allowed and all others are encoded with=
followed by two hex digits. Additionally in line 188 is an invalid hex sequence=C3=9=C3=9FF
, guessing this should be=C3=9F
which isß
in utf-8.I will add an error message to the script to help identifying the culprit line(s).
After correcting the errors the file can be converted successfully. vcard2qp.corrected.txt
(Note: There is one more possible source of error, since my script ignores the
CHARSET=UTF-8
in quoted printable lines and instead uses always the input encoding, which can be given as parameter. For your file this is not a problem though.)thank you!