bug 407768 - Encoding issues in Minotaur - reviewer: Robcee

This commit is contained in:
ctalbert@mozilla.com 2008-01-09 15:56:35 -08:00
Родитель 65d455e178
Коммит 166154bfed
1 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -49,7 +49,7 @@ var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Ci.nsIWindowWatcher); .getService(Ci.nsIWindowWatcher);
var w = ww.openWindow(null,"chrome://browser/content/browser.xul",null,null,null); var w = ww.openWindow(null,"chrome://browser/content/browser.xul",null,null,null);
var gOutFile; var gConvStream;
function createOutputFile() { function createOutputFile() {
var dirServices = Cc["@mozilla.org/file/directory_service;1"] var dirServices = Cc["@mozilla.org/file/directory_service;1"]
@ -60,14 +60,18 @@ function createOutputFile() {
file.remove(false); file.remove(false);
} }
gOutFile = Cc["@mozilla.org/network/file-output-stream;1"] var outFile = Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream); .createInstance(Ci.nsIFileOutputStream);
const MODE_WRONLY = 0x02; const MODE_WRONLY = 0x02;
const MODE_CREATE = 0x08; const MODE_CREATE = 0x08;
const MODE_TRUNCATE = 0x20; const MODE_TRUNCATE = 0x20;
const MODE_APPEND = 0x10; const MODE_APPEND = 0x10;
gOutFile.init(file, MODE_WRONLY | MODE_CREATE | MODE_APPEND | MODE_TRUNCATE, outFile.init(file, MODE_WRONLY | MODE_CREATE | MODE_APPEND | MODE_TRUNCATE,
0600, 0); 0600, 0);
// Need to create the converterStream
gConvStream = Cc["@mozilla.org/intl/converter-output-stream;1"]
.createInstance(Ci.nsIConverterOutputStream);
gConvStream.init(outFile, "UTF-8", 0, 0x0000);
// Seed the file by writing the XML header // Seed the file by writing the XML header
output("<?xml version=\"1.0\"?>\n<testrun>"); output("<?xml version=\"1.0\"?>\n<testrun>");
@ -75,8 +79,7 @@ function createOutputFile() {
function output(s) { function output(s) {
s = escape(s); s = escape(s);
gOutFile.write(s, s.length); gConvStream.writeString(s);
dump(s);
} }
function escape(s) { function escape(s) {
@ -86,8 +89,7 @@ function escape(s) {
} }
function closeOutputFile() { function closeOutputFile() {
output("\n</testrun>\n"); output("\n</testrun>\n");
gOutFile.flush(); gConvStream.close();
gOutFile.close();
} }
function listEngines() { function listEngines() {