1

i have following problem: i need to convert this text: "test+%2B%C4%8D%C5%A5%C5%BE%C3%BD" to this "test +čťžý" i can do it online using this website : https://2cyr.com/decode/ on the website it says that the source text is in "WINDOWS-1251" character set and i need it to be in is "UTF-8".

in other words, i need to see the accented characters like this "čšť" not like this "%2B%C4" how can i achieve this? i tried to google it but none of the solutions i found help me. Thank you.

1 Answer 1

3

The function unquote from Python's urllib will convert these characters from their %XX escaped forms back into UTF-8. Documentation here: https://docs.python.org/3/library/urllib.parse.html#urllib.parse.unquote

>>> from urllib.parse import unquote >>> unquote('test+%2B%C4%8D%C5%A5%C5%BE%C3%BD') 'test++čťžý' 
Sign up to request clarification or add additional context in comments.

1 Comment

Technically unquote converts the characters to unicode, not UTF-8, because it returns a str, not bytes.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.