An existing application passes XML to sproc in SQLServer 2000, the input data type is TEXT; XML is derived from Dataset.GetXML (). But I noticed that it does not indicate the encoding.
So, when a user sneaks into an unacceptable character into a dataset, in particular ASCII 146 (which appears to be an apostrophe) instead of ASCII 39 (a single quote), sproc does not work.
One approach is to getXML result prefix with
<?xml version="1.0" encoding="ISO-8859-1"?>
This works in this case, but what would be a more correct approach to ensure that sproc does not crash (if other unexpected characters appear)?
PS. I suspect that the user prints the text in MS-Word or a similar editor, copies and pastes into the application input fields; I probably want the user to continue working this way, just need to prevent crashes.
EDIT: I am looking for answers that confirm or deny some aspects, for example:
- according to the header, what is the default encoding if none are specified in XML?
- Is the encoding ISO-8859-1 used correctly?
- if there is a better encoding that will cover more characters in the English-speaking world and, therefore, less likely to lead to an error in sproc?
- Would you filter the application for standard ASCII (only from 0 to 127) at the user interface level and not allow advanced ASCII?
- any other relevant data.
source share