Replace an invalid character with a single quote