Handle escaped characters in strings correctly