added some escaping and UTF encoding