Adds option to encode unsafe characters in text content

Thanks for this module. I like its simplicity. I have added a patch to escape invalid characters in text content. Please adjust / merge / reject.