you can&#x27;t sanitize a name, because a name is not dirty.<p>Sanitization basically means taking a string which purports to conform to a particular grammar, verifying that it does and, if it does not <i>forcing it to</i>. But names don&#x27;t really have a formal grammar, so you can&#x27;t &#x27;sanitize&#x27; one much (maybe trimming leading and trailing white space and normalizing internal white space runs to a single space? Maybe?).<p><i>Gijs in \&#x27;t Veld</i> is a &#x27;sanitized&#x27; string in a grammar which doesn&#x27;t allow bare apostrophes - such as some string literal syntaxes - and escapes them with a backslash. If someone presents you with a string <i>Gijs in &#x27;t Veld</i> with the claim that it conforms to that grammar, they are wrong, and maybe the right thing to do then is to sanitize it as you did. Or you could strip the apostrophe out. Or replace it with a question mark. Your sanitization approach is arbitrary because by definition the string you have been given does not conform to the grammar it purports to so you do not know what to do with that bare apostrophe. Sanitization is not &#x27;representation preserving&#x27; because it converts broken, ungrammatical strings (which therefore have undefined meaning) into grammatical strings (which have a defined meaning that you hope is what was intended).<p>But this string <i>hasn&#x27;t</i> been presented as a string conforming to that grammar. It&#x27;s been presented as a name, which is essentially an arbitrary valid Unicode string. The process of converting it to the restricted grammar with no bare apostrophes but retaining representation of the same underlying string is not &#x27;sanitization&#x27; but &#x27;encoding&#x27;. It is representation preserving (so long as the grammar to which we are encoding is capable of representing the string).<p>Failure to grasp the differences between these operations is what causes people to wind up sending people like this poor gentleman emails addressed to <i>Gijs in \&amp;amp;#37;t Veld</i>