cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting UTF non-English chars in XML file with UNLOAD

vlad1
Participant
0 Kudos

Hi, SQL Anywhere 17.0.11.7058

We have a database with CHAR encoding set Western Latin 1252, and NCHAR encoding set UTF-8 which is giving us a problem when we are exporting some NVARCHAR non-English characters. We are doing this by using UNLOAD SELECT XMLGEN call on a SELECT query to save the results of the query in XML format.

We get the error message

Control character in XML output
SQLCODE=-911, ODBC 3 State = "HY000"

Our procedure calls a statement

EXECUTE IMMEDIATE 'UNLOAD SELECT XMLGEN( ''<?xml version="1.0" encoding="UTF-8" ?><Root>{$x}</Root>'',
SELECT field1, field2 etc etc...
for xml auto, elements) AS x ) TO ' + filepath_filename + ' ENCODING ''UTF-8'' format ASCII quotes off escapes off';

and if any of the fields we are selecting gets a non-English character, we get the above message.

Curiously, when I try it on the copy of the database which has both CHAR and NCHAR encoding sets of UTF-8, then no problems at all - XML file is output and saved with all sorts of non-English characters without any problems.

But I'd prefer to keep CHAR encoding set of Latin1252 / NCHAR of UTF-8 if possible, so I'd like to see if I can resolve the above problem?

Cheers

chris_keating
Advisor
Advisor

Is this the same question raised in UTF-8 characters stored OK, but output via XML procedure fails? - SQLA Forum (sap.com)?

John posted yesterday to that thread that the SQLA XML uses the CHAR character set. This is the correct answer. To avoid the error, you have to ensure that the characters that you wish to be emitted as XML can be represented in that character set. For example, you can store study in English and French (étude) but not in Greek as Greek characters cannot be represented in 1252.

If you have follow-up questions, I suggest that you put those in the SQL Anywhere forum thread.

Accepted Solutions (1)

Accepted Solutions (1)

vlad1
Participant
0 Kudos

Hi Chris, yes, same question. At the time when I posted here, there wasn't a lot of info on the other SQL Anywhere forum. Googling brought me here so I'd figure I'd try here as well.

No worries, I will use that other forum in the future. THanks

Answers (0)