browse/utils: Robustify content encoding detection
When attempting to re-encode non UTF-8 textual content, use chardet to find the encoding first and use it if the detection confidence is really high.
Previously some encoding like SHIFT_JIS (for japanese language) were not correctly detected and thus content were badly rendered in the browse Web UI (see example).
Migrated from D7197 (view on Phabricator)