question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: string argument should contain only ASCII characters

See original GitHub issue

Hi

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:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jowavecommented, Oct 30, 2022

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.)

0reactions
wurzelbutzcommented, Oct 30, 2022

thank you!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found