Properly encoding content strings for editing and after edit