parse strings to escape quotes etc