Display special characters for html

Sometimes we need to create a static html page which displays words with special characters like Ä, ä, Ö, ö, Ü, ü and ß. In order to make these characters can be displayed correctly by webbrowser, we need to convert them in html special character format. I use awk to convert all of those characters into html format.

In this example I need to list file names in a folder and save it as html file. Here is my code:

ls -la /path/to/folder/ | awk '{ 
 gsub (/ /,"\\ ")
 gsub (/ä/,"\\ä")
 gsub (/ö/,"\\ö")
 gsub (/ü/,"\\ü")
 gsub (/ß/,"\\ß")
 gsub (/Ä/,"\\Ä")
 gsub (/Ö/,"\\Ö")
 gsub (/Ü/,"\\&Uuml;") ;print $0"<br>"}' >> /path/to/filename.html

With that code above I can see a list of files using webbrowser and get appearance as if I would list it using linux terminal.