Make http charset detection code more robust

Fixes #321
Changelog for HTTP character set dections
Merge branch 'pr/325'