Invalid characters saved in database

Hi all,

I am using AX2012 R2 and have a very complex problem in AX. Sometimes we have invalid characters saved in the database, you don't see it in the forms but when you export the files to XML they will appear. After that we have an error in the application who is trying to read this XML.

Example: a customer number looks like 226699 but when you export it to XML "??226699" will be exported. Or characters like "&#x1F" will be se shown in the XML in a text.

Anyone any idea how to fix this issue? Offcourse I can check/clean the data before exporting. But this will be a big performance killer...

Thanks in advance!