+ 13

How to convert special characters into HTML entities?

I want to convert an arbitrary text into a text with the corresponding HTML-entities and I am searching for a dedicated Python module + method for replacing the special characters into HTML-entities. E.g. the conversion should be like Ă€ -> &auml; ö -> &ouml; ĂŒ -> &uuml; ß -> &szlig; I could do this for a couple of characters with a dictionary, but I want to have a comprehensive solution which covers all available characters outside the standard character set a-z and A-Z for many different languages. In the attached file https://code.sololearn.com/cn9CBAh8mLff/?ref=app where I use XML, the '<'-character is automatically converted into its entity &lt;. Why does this not occur with the characters 'Ă€Ă¶ĂŒ'? How would I have to proceed to solve this?

12th Oct 2020, 11:04 PM
Jan Markus
4 Answers
+ 5
I don't know it is correct answer or not. Find starting and ending number for all characters. from https://html-css-js.com/html/character-codes/ then use for loop to get all characters. https://code.sololearn.com/WcB3dPe9TxHg/?ref=app
12th Oct 2020, 11:14 PM
🇼🇳Vivek🇼🇳
🇼🇳Vivek🇼🇳 - avatar