I have a problem with character encodings that I hope someone might be
able to help with. It's not directly a network question, I suppose, so
feel free to point me more appropriate.
I have an extension which renders WML by registering itself as a
StreamConverter and converting WML to HTML using XSLT. I receive the
data via StreamListener's onDataAvailable method as follows:
WMLStreamConverter.prototype.onDataAvailable =
function (aRequest, aContext, aInputStream, aOffset, aCount) {
var si =
Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance();
si =
si.QueryInterface(Components.interfaces.nsIScriptableInputStream);
si.init(aInputStream);
this.data += si.read(aCount);
}
This seems to go wrong with some character encodings. I think this is
probably because I receive the data as a byte array and the conversion
to a string is not intelligent enough. For example if the input data is
UTF-8, I suspect I am converting each byte of a multi-byte character
sequence into a UTF-16 character.
More concretely (if Google Groups manages to post this correctly), a
text of "èååç" originally in UTF-8 gets converted to
"ÃÂÂÃÂÂÃÂÂÃ".
So is there a scriptable way of converting a byte array in a known
encoding to a correctly-decoded Javascript string? Or is there another
way I can register as a listener to get Unicode data?
Matthew Wilson
_______________________________________________
Mozilla-netlib mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-netlib