[Expat-discuss] Expat and JavaScript

Karl Waclawek karl at waclawek.net
Wed Aug 2 19:05:07 CEST 2006


Franky Braem wrote:
>>
>> How does p.currentElement.name get its value from Expat
> This is how it is done:
>
> void XMLParser::StartElementHandler(void *userData,
>                                    const XML_Char *name,
>                                    const XML_Char **atts)
> {
>    wxMBConvUTF16 conv;
>    XMLParser *parser = (XMLParser*) userData;
>
>    wxString element(name, conv);
>
>    ...
>
>    jsval rval;
>    jsval argv[] =
>    {
>        JS_NewUCStringCopyN(cx, (jschar *) element.c_str(), 
> element.length()));
>        OBJECT_TO_JSVAL(objAttr)
>    };
>
>    wxJS_CallFunctionProperty(parser->m_cx, parser->m_obj, 
> "onStartElement",
>                              2, argv, &rval);
> }

I know nothing about the wx API, but it seems that maybe you are calling the
wxstring constructor with the wrong arguments. "name" is already in 
UTF-16 encoding,
so why pass an instance of wxMBConvUTF16 (Google indicates this is used 
for converting
from UTF-8 to UTF-16)?

Karl


More information about the Expat-discuss mailing list