cleanup
encode a string