[Expat-discuss] Expat and JavaScript

Karl Waclawek karl at waclawek.net
Tue Aug 1 15:26:47 CEST 2006


Franky Braem wrote:
> I'm porting expat to JavaScript (using SpiderMonkey, see my wxJS 
> project). The application is in Unicode.
> I have the following problem:
>
> When I pass a normal JavaScript string (SpiderMonkey uses UTF-16) to a 
> 'print' method I don't have to do any conversions to write the data to 
> stdout.
> When I use a string generated by expat (it is build in UNICODE and 
> creates data in UTF-16) I have to do a conversion before I can send the 
> string to the 'print' method.
> When I look at the expat string in debug mode, I see all weird Chinese 
> characters. When I debug the normal JavaScript string, I see normal text.
> Is there a conversion needed between SpiderMonkey and Expat?
>
> Maybe this JavaScript code makes some things clearer:
>
> p.parse('<tag1 attr="1" attr2="2"><child1>child</child1></tag1>', true);
> if ( p.currentElement.name == "tag1")
> {
>  wxJS.print("Ok");
> }
> else
> {
>  wxJS.print("Not ok");
> }
> wxJS.print(p.currentElement.name);
>
> The comparison always fails (all though the parsing in expat went fine)
>
>   

How does p.currentElement.name get its value from Expat?

Karl


More information about the Expat-discuss mailing list