Have a look at this link from w3, it tells me that:
In HTML, there is a list of some built-in character names like é
for é but XML does not have this. In XML, there are only five built-in character entities: <
, >
, &
, "
and '
for <, >, &, " and ' respectively. You can define your own entities in a Document Type Definition, or you can use any Unicode character (see next item).
In HTML, there are also numeric character references, such as &
for &. You can refer to any Unicode character, but the number is decimal, whereas in the Unicode tables the number is usually in hexadecimal. XML also allows hexadecimal references: &
for example.
This leads me to believe that, é
might work for an é character.
Also the information at this link from Microsoft states that:
SQLXML 4.0 relies upon the limited support for DTDs provided in SQL Server. SQL Server allows for an internal DTD in xml data type data, which can be used to supply default values and to replace entity references with their expanded contents. SQLXML passes the XML data "as is" (including the internal DTD) to the server. You can convert DTDs to XML Schema (XSD) documents using third-party tools, and load the data with inline XSD schemas into the database.
But all this does not help you if you don't have control over the incoming XML stream. I doubt that it is possible to save an é (or any special character for that matter, except for the built in character entities mentioned above) inside an XML document into an SQL Server XML field, without either adding a DTD or replacing the character with its hexadecimal reference counterpart. In both cases you would need to be able to modify the XML before it goes into the database.
Just a quick example for anyone wanting to go down the "adding a DTD" route.
Here's how to add an internal DTD to an xml file which declares an entity for an é character:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [<!ENTITY eacute "é">]>
<root>
<RegionName>Québec</RegionName>
</root>
If you go here and search on the page "Ctrl+F" for "eacute", you end up in a list with examples for other characters which you could just copy and paste into your own internal DTD.
Edit
You could off course add all entities as they are specified at the link above: <!ENTITY eacute "é"><!ENTITY .. // Next entity>
, or just copy them all from this file. I do understand how adding an internal DTD to every single XML file you add to the database isn't such a good idea. I would be interested to know if adding it for 1 file fixes your issue though.
utf-8
declaration in the xml is why it fails. FWIW, if you remove theencoding
declaration entirely, or change it toencoding="UTF-16"
the insert succeeds in CF10, with the "Enable High ASCII characters ..." setting enabled. (Changing the encoding of just the string had no effect.) However, I do not know if this has any negative side affects.cfhttp
, a web service call, a rest call, etc). Why I ask because if they are providing it in UTF-8, you will need to tell CF on your end of things that too. Which is what it seems is not happening. If you just browse to the web service URL in a browser, is the data returned to the browser correctly, and what encoding is the data coming down as?