Updated string-encode version