C++ – UTF8 encoded text cones in a TDesC8 variable from Xml-parser in Symbian


I'm using Carbide.c++ 2.0 to create a S60 application that consumes my own webservice.
I've used the Yahoo! Image Search example as a starting point and data is shipped back and forth nicely. Problems occur when there are non-english characters in the reply so the text presented to the user in the listbox is incorrect.
The XML-document the webservice replies with is UTF8 encoded and when it's parsed the text is presented in a TDesC8 parameter to a function.

  1. What datatype should I use to store the UTF8 text?
  2. How do I convert UTF8 encoded text stored in a TDesC8 variable/parameter to a variable of the datatype above?
  3. Are there perhaps other methods in the Xml-class that I can implement in order to get a differend datatype of the parameter?

Best Solution

  1. S60 is using 16-bit unicode characters. So any subclass of TDesC16 will do.
  2. Use the native charconv library. Include charconv.h, link with charconv.lib and call e.g. CnvUtfConverter::ConvertToUnicodeFromUtf8().
  3. Depends on which "Xml-class" you are talking about.