Fix unicode handling in 'View HTML code as formated text'. Fixes #667
Optimizations and better newlines handling
Merge pull request #679 from enikesha/htmlfix

Fix unicode handling in 'View HTML code as formated text'. Fixes #667