We have some incoming inventory XMLs which has Spanish characters. We store the XML in a SQL Server DB table with XML datatype for the column. XML datatype already supports UTF-8 encoding, so there shouldn’t be any issue with storing Spanish characters.
If I directly use an insert command to store Spanish characters on SQL Server, they remain intact. But when I try to insert the XML using system.db.runUpdateQuery() with N’ ‘ prefix or system.db.runPrepUpdate with ? parameters from a script, the Spanish encoding breaks during storage in DB. Garbled characters get stored.
Has anyone else seen this behavior from Ignition script or know a fix for this ?
I also saw this old post. Not sure whether a similar issue could be there for XML data type on SQL Server DB - Special Characters
Thanks for this tip. Encoding was breaking when XML was being retrieved from an url. I used the following code to fix it along with system.db.runPrepUpdate()
Interesting. getText uses the charset returned in the response headers, falling back to UTF-8 automatically if not specified. You had to add the explicit charset to get it to work, or you had to migrate to system.net.httpClient vs system.net.httpGet or something?