I have many HTML files containing mixed unicode strings like \303\243 and printable characters like %s. What I'd like to do is converting the unicode strings into printable characters in a safe way.I found that printf from GNU coreutils converts them automatically, but I also learned the hard way some time ago that printf is not trustworthy if you don't know what is going to be printed:$ env printf $(cat filename.htm)printf: %20M: invalid conversion specificationI also know that bash can do conversions like this, but I'd have to loop through the file with a regex, which is not safe at all:$ echo $'\303\243'Is there such a command-line tool that can process these files in a clean and safe way?
Safely convert unicode strings to printable characters
bash;shell;command line;awk;python
If the files don't have other backslashes:$ printf %b\\n 'aa\303\243'aaIf they do, you could double backslashes that aren't followed by integers:$ printf %b\\n $(sed -E 's/\\/\\\\/g;s/\\(\\[0-7])/\1/g' <<< '\\a\na\303\243')\\a\na