[Expat-discuss] Expat and JavaScript encoding
Franky Braem
f.braem at skynet.be
Sat Jul 29 22:16:40 CEST 2006
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)
Franky.
More information about the Expat-discuss
mailing list