Shared utility method for encoding HTML special chars

* by default don't double encode already existing HTML chars (like `&nbsp;`)
* by default use `default_charset` encoding from ini file or fall back to `UTF-8` encoding
* replaced `htmlspecialchars` method in almost every ATK file except some where original method call is probably more appropriate (like debug messages)