/* Test case for bug 340714 * * Uses nsIConverterInputStream to decode UTF-16 text with all combinations * of UTF-16BE and UTF-16LE with and without BOM. * * Sample text is: "Все счастливые семьи похожи друг на друга, каждая несчастливая семья несчастлива по-своему." * * The enclosing quotation marks are included in the sample text to test that * UTF-16LE is recognized even when there is no BOM and the UTF-16LE decoder is * not explicitly called. This only works when the first character of the text * is an eight-bit character.
*/
function testCase(withBOM, charset, charsetDec, decoder, bufferLength) { var dataURI = "data:text/plain;charset=" + charsetDec + "," + makeText(withBOM, charset);
var ConverterInputStream = Components.Constructor( "@mozilla.org/intl/converter-input-stream;1", "nsIConverterInputStream", "init"
);
var channel = NetUtil.newChannel({
uri: dataURI,
loadUsingSystemPrincipal: true,
}); var testInputStream = channel.open(); var testConverter = new ConverterInputStream(
testInputStream,
decoder,
bufferLength,
0xfffd
);
if (!(testConverter instanceof Ci.nsIUnicharLineInputStream)) { thrownew Error("not line input stream");
}
var outStr = ""; var more; do { // read the line and check for eof var line = {};
more = testConverter.readLine(line);
outStr += line.value;
} while (more);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.