rem: str = "\n</body>\n</html>\n"; aStream.write(str, str.length); 
add:   var convStream = Components.classes["@mozilla.org/intl/converter-output-stream;1"] .getService(Components.interfaces.nsIConverterOutputStream); convStream.init(aStream, 'UTF-8', 0, 0x0000);  var str = html.toXMLString() convStream.writeString(str); 
context: function html_exportToStream(aStream, aCount, aItems) {    var str =         "<html>\n" +        "<head>\n" +         "<title>HTMLTitle</title>\n" +        "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" +        "</head>\n"+ "<body bgcolor=\"#FFFFFF\" text=\"#000000\">\n";    aStream.write(str, str.length);       for each (item in aItems) {        try {            item = item.QueryInterface(Components.interfaces.calIEvent);        } catch(e) {            continue;        }        var start = item.startDate.jsDate;        var end = item.endDate.jsDate;        //var when = dateFormat.formatInterval(start, end, calendarEvent.allDay);        var when = item.startDate + " -- " + item.endDate;        dump(when+"\n");        var desc = item.description;        if (desc == null)          desc = "";        if (desc.length > 0) {           if (desc.indexOf("\n ") >= 0 || desc.indexOf("\n\t") >= 0 ||              desc.indexOf(" ") == 0 || desc.indexOf("\t") == 0)            // (RegExp /^[ \t]/ doesn't work.)            // contains indented preformatted text after beginning or newline            // so preserve indentation with PRE.            desc = "<PRE>"+desc+"</PRE>\n";          else            // no indentation, so preserve text line breaks in html with BR            desc = "<P>"+desc.replace(/\n/g, "<BR>\n")+"</P>\n";        }        // use div around each event so events are navigable via DOM.        str  = "<div><p>";        str += "<B>Title: </B>\t" + item.title + "<BR>\n";        str += "<B>When: </B>\t" + when.replace("--", "&ndash;") + "<BR>\n";        str += "<B>Where: </B>\t" + item.location + "<BR>\n";        // str += "<B>Organiser: </B>\t" + Event.???        str += "</p>\n";        str += desc; // may be empty        str += "</div>\n";        aStream.write(str, str.length);    }    str = "\n</body>\n</html>\n";    aStream.write(str, str.length);    return;};
meta: 5872	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/5872/4ea60d329e786df91571e10f76a5eb6e4c0cb197/calHtmlExport.js/buggy/calendar/import-export/calHtmlExport.js