rem:     var sliceStringArray = new Array(); for (var start = 0, end; start < (end = Math.min(result.length, start + 32768)); start = end) { var slice = result.slice(start, end); var sliceString = String.fromCharCode.apply(null, slice); sliceStringArray[sliceStringArray.length] = sliceString; } result = sliceStringArray.join(""); 
add:   try { var unicodeConverter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"] .createInstance(Components.interfaces.nsIScriptableUnicodeConverter);  unicodeConverter.charset = "UTF-8"; var result = unicodeConverter.convertFromByteArray( result, result.length ); } catch(e) {       var sliceStringArray = new Array(); for (var start = 0, end; start < (end = Math.min(result.length, start + 32768)); start = end) { var slice = result.slice(start, end); var sliceString = String.fromCharCode.apply(null, slice); sliceStringArray[sliceStringArray.length] = sliceString; } result = sliceStringArray.join(""); } 
context:       onStreamComplete: function(loader, ctxt, status, resultLength, result)      {         // revert from "wait" cursor set by getRemoteCalendarText (below)         window.setCursor( "auto" );         var calendarStringBundle = srGetStrBundle("chrome://calendar/locale/calendar.properties");         var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]                                       .getService(Components.interfaces.nsIPromptService);         var retval = false;         if( typeof( result ) != "string" ) { //for 1.7 compatibility           // Result is an array of integer unicode values.           // Convert to string by applying String.fromCharCode static function.           // Function.apply can take array of length < expt(2, 16),           // so convert slices half that length to strings, then join strings.           var sliceStringArray = new Array();           for (var start = 0, end;                start < (end = Math.min(result.length, start + 32768));                start = end) {              var slice = result.slice(start, end);             var sliceString = String.fromCharCode.apply(null, slice);             sliceStringArray[sliceStringArray.length] = sliceString;           }           result = sliceStringArray.join("");         }         var ch;         try {           ch = loader.request.QueryInterface(Components.interfaces.nsIHttpChannel);         } catch(e) {         }         if (ch && !ch.requestSucceeded) {           promptService.alert(null, calendarStringBundle.GetStringFromName('errorTitle'),                               calendarStringBundle.formatStringFromName('httpError',[ch.responseStatus, ch.responseStatusText],2));         }         else if (ch && !Components.isSuccessCode(loader.request.status)) {           // XXX this should be made human-readable.           promptService.alert(null, calendarStringBundle.GetStringFromName('errorTitle'),                               calendarStringBundle.formatStringFromName('otherError',[loader.request.status.toString(16)],1));         }         //check to make sure its actually a calendar file, if not return.         else if( result.indexOf( "BEGIN:VCALENDAR" ) == -1 )         {           promptService.alert(null, calendarStringBundle.GetStringFromName('errorTitle'),                               calendarStringBundle.formatStringFromName('contentError',[Channel.URI.spec, result],2));         } else {             onResponse( result );             retval = true;         }         if( gNextSubNodeToRefresh )            gCalendarWindow.calendarManager.refreshAllRemoteCalendars();         return retval;      }
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/bfc2f3909e3cea681c44c22161d4447970edd6a4/calendarManager.js/clean/calendar/resources/content/calendarManager.js