Make special characters handling more generic