[Expat-discuss] XML_Parse const char *s param?
Karl Waclawek
karl at waclawek.net
Wed Mar 26 19:13:22 EST 2003
> I have a question about the XML_Parse function, which I unfortunately
> couldn't find an answer to in the documentation:
>
> XML_Parse() takes a |const char *s| parameter, which is a buffer
> containing some or all of a document. This is notably different from the
> callback functions which take |XML_Char*|. That sort of indicates to me
> that you can only pass in a buffer of single-byte characters (whether
> those are UTF-8, ISO-8859-1 or whatever, they're all |char*|).
>
> So my question is, what if I have my data in UCS-2? Do I have to convert
> it all down to UTF-8 before passing it into XML_Parse? I tried simply
> casting the wchar_t* buffer I have down to a char* buffer, but that
> obviously didn't work...
Expat expects a buffer of bytes, that is all.
Is there a better way to declare such a buffer?
> Can somebody please explain to me exactly what XML_Parse() expects of a
> buffer that's passed to it?
Just a buffer of bytes, regardless of encoding.
Expat handles buffer boundaries properly, so even
if a buffer ends in the middle of a multi-byte character
it is not a problem.
Karl
More information about the Expat-discuss
mailing list