Load all files xpcom/ files as UTF-8

This fixes corrupted em dashes from citeproc-js:

https://forums.zotero.org/discussion/78327/dash-in-ama-is-producing-odd-characters-a%C2%80%C2%94
This commit is contained in:
Dan Stillman 2019-07-25 07:39:32 -04:00
parent f6f2faf675
commit 66f2d177a9

View file

@ -261,11 +261,11 @@ function makeZoteroContext(isConnector) {
var subscriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
// Load zotero.js first
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[0] + ".js", zContext);
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[0] + ".js", zContext, 'utf-8');
// Load CiteProc into Zotero.CiteProc namespace
zContext.Zotero.CiteProc = {"Zotero":zContext.Zotero};
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/citeproc.js", zContext.Zotero.CiteProc);
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/citeproc.js", zContext.Zotero.CiteProc, 'utf-8');
// Load XRegExp object into Zotero.XRegExp
const xregexpFiles = [
@ -286,13 +286,13 @@ function makeZoteroContext(isConnector) {
'addons/unicode/unicode-zotero' //adds support for some Unicode categories used in Zotero
];
for (var i=0; i<xregexpFiles.length; i++) {
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/xregexp/" + xregexpFiles[i] + ".js", zContext);
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/xregexp/" + xregexpFiles[i] + ".js", zContext, 'utf-8');
}
// Load remaining xpcomFiles
for (var i=1; i<xpcomFilesAll.length; i++) {
try {
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[i] + ".js", zContext);
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[i] + ".js", zContext, 'utf-8');
}
catch (e) {
Components.utils.reportError("Error loading " + xpcomFilesAll[i] + ".js", zContext);
@ -303,7 +303,7 @@ function makeZoteroContext(isConnector) {
// Load xpcomFiles for specific mode
for (let xpcomFile of (isConnector ? xpcomFilesConnector : xpcomFilesLocal)) {
try {
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFile + ".js", zContext, "UTF-8");
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFile + ".js", zContext, "utf-8");
}
catch (e) {
dump("Error loading " + xpcomFile + ".js\n\n");
@ -326,12 +326,12 @@ function makeZoteroContext(isConnector) {
];
zContext.Zotero.RDF = {Zotero:zContext.Zotero};
for (var i=0; i<rdfXpcomFiles.length; i++) {
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + rdfXpcomFiles[i] + ".js", zContext.Zotero.RDF);
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + rdfXpcomFiles[i] + ".js", zContext.Zotero.RDF, 'utf-8');
}
if(isStandalone()) {
// If isStandalone, load standalone.js
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/standalone.js", zContext);
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/standalone.js", zContext, 'utf-8');
}
// add connector-related properties