I have the following string:
Customer sale 88% in urm 50
Quoted with urllib.parse.quote, it becomes:
Customer%20sale%2088%25%20in%20urm%2050%27
Then I need to limit its length to a maximum of 30 characters and I use value[:30].
The problem is that it becomes "Customer%20sale%2088%25%20in%" which is not valid:
The last % is part of %20 from quoted string and makes it an invalid quoted string.
I don't have control over the original string, and the final result needs to have a maximum 30 length, so I can't truncate it beforehand.
What approach would be feasible?
