You could probably use javascript's built in `escape` rather than implementing and using escape_html_characters.