The standard Symbian API-s do not support UTF-16.
On the other hand, user-presentable strings are handled in 16-bit Unicode format (UCS-2). The similarities and differences are described on Wikipedia for example: http://en.wikipedia.org/wiki/UTF-16
So, treating UTF-16 data as simple UCS-2 may work.
An approach which could be tested:
1) you probably get the actual data in a 8-bit descriptor (as it comes from a server), so the bytes should be paired into a 16-bit descriptor
2) a 16-bit descriptor can be UTF-8 encoded with CnvUtfConveter class
3) the UTF-8 encoded descriptor can be fed to the parser
4) whatever 8-bit descriptor comes back from the parser is actually UTF-8 encoded, but CnvUtfConverter can convert in both directions. At the end you will theoretically get back UTF-16 encoded content from elements/attributes, and you can just pretend that they are simple UCS-2 strings and try displaying them which will work most of the time.
Problems which may arise:
- byte order: it is easy, try the other one
- if the XML document has a standard head with encoding specification, the parser may look strange if the encoding says UTF-16, this issue can be handled via explicitly checking this part and replacing if necessary
Code:
"TDes8 input8;" // whatever input you have at the beginning
TPtr16 inputUCS2(reinterpret_cast<TUint16*>(&input8[0]),input8.Length()/2,input8.Length()/2);
HBufC8 *inputUTF8=CnvUtfConverter::ConvertFromUnicodeToUtf8L(inputUCS2);
could be the first try, and pass *inputUTF8 to the XML parser.
But it is actually better to check it first with your own eyes. If it is a complete mess, then ByteOrder::Swap16 can swap the bytes for you
Code:
for(TInt i=0;i<inputUCS2.Length();i++)inputUCS2[i]=ByteOrder::Swap16(inputUCS2[i]);