Encode special characters properly to avoid parsing problems.