Select to view content in your preferred language

Doesn't the parameter of Table::GetDefinition need to be std::wstring?

1495
6
02-15-2011 12:26 AM
SatoruGUNJI
Esri Contributor
The definition XML document is UTF-8:

<?xml version="1.0" encoding="UTF-8"?>
<DataElement xmlns:esri="http://www.esri.com/schemas/ArcGIS/10.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="esri:DEFeatureClass">
 ...

When the definition contains Japanese strings, these characters are garbled.
0 Kudos
6 Replies
LanceShipman
Esri Regular Contributor
Can you send me example containing Japanese strings.
lshipman@esri.com
0 Kudos
LanceShipman
Esri Regular Contributor
All XML data in the File Geodatabase API is in the form of a UTF-8 encoded string, therefore using std::wstring is not appropriate.  UTF-8 is a variable length Unicode character encoding, but wstring is a wide character, or UTF-16, Unicode character encoding.

Unfortunately, C++ does not have built in support for UTF-8 encoded strings.  Because of this, if you need to read or print a UTF-8 encoded string, you must first convert it to another character encoding, such as wchar_t (also known as UTF-16).  The Windows run time library provides a function for this purpose: MultiByteToWideChar.  Be sure to pass �??CP_UTF8�?� as the value of the first parameter.
0 Kudos
SatoruGUNJI
Esri Contributor
Thank you very much for advice.
I will test MultiByteToWideChar.
0 Kudos
SatoruGUNJI
Esri Contributor
MultiByteToWideChar works fine.
I will control these XML in program. Does Esri have the suggested XML parser and samples?
0 Kudos
LanceShipman
Esri Regular Contributor
We are using libXml. Use whatever you find convenient.
0 Kudos
SatoruGUNJI
Esri Contributor
Thank you for information.
I am using the Xerces. This can get the Geodatabase XML properties.
0 Kudos