Hi Rafael,
you must understand that XMLCh are made of UTF-16 character (i.e.
Unicode), while what you want to use is plain ASCII, so you need to
perform the conversion from ASCII to Unicode.
You have three choices:
1) if your compiler supports Unicode characters in the source code
(usually by the L modifier) you can write
static const XMLCh gFileToTrap[] = L"personal.dtd";
2) if your compiler doesn't support Unicode character, you have to
write the array character by character, either using
static const XMLCh gFileToTrap[] =
{
chLatin_p, chLatin_e, chLatin_r, chLatin_s, chLatin_o, chLatin_n
, chLatin_a, chLatin_l, chPeriod, chLatin_d, chLatin_t, chLatin_d,
, chNull
};
or
static const XMLCh gFileToTrap[] =
{
'p', 'e', 'r', 's', 'o', 'n', 'a', 'l', '.', 'd', 't', 'd', 0
};
3) if you don't option 2, you have to do the conversion at runtime
using a transcoder, like in
const XMLCh* gFileToTrap=XMLString::transcode("personal.dtd");
Don't forget to delete the string by using
XMLString::release(&gFileToTrap); also, you must allocate it after
XMLPlatformUtils::initialize and deallocate it before
XMLPlatformUtils::terminate.
Hope this helps,
Alberto
At 16.58 18/11/2005 +0000, Rafael Sousa (Ext_Altior) wrote:
Hi all!
I'm having trouble working with XMLCh strings...
For example, in the Redirect sample a constant XMLCh string is defined
this way:
static const XMLCh gFileToTrap[] =
{
chLatin_p, chLatin_e, chLatin_r, chLatin_s, chLatin_o, chLatin_n
, chLatin_a, chLatin_l, chPeriod, chLatin_d, chLatin_t,
chLatin_d, chNull
};
But is this the only way? Can't I create one directly from a string of
caracters, like:
static const XMLCh gFileToTrap[] = "personal.dtd";
What would be really nice was to be able to create a XMLCh* from a
char*... Can this be done easily?
Thanks!
Rafael Sousa