From 8cce7d7cd5b7e49214b84ce45e791b4fc1bcb4a6 Mon Sep 17 00:00:00 2001 From: Luca Rath-Heel Date: Mon, 8 Apr 2024 12:03:01 +0200 Subject: [PATCH 1/2] Update universaldetector.js --- src/universaldetector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universaldetector.js b/src/universaldetector.js index 3f64c60..203ac09 100644 --- a/src/universaldetector.js +++ b/src/universaldetector.js @@ -107,7 +107,7 @@ function UniversalDetector(options) { if (!options.detectEncodings) { return true; } - lowerDetectedEncodings = options.detectEncodings.map(encoding => encoding.toLowerCase()); + const lowerDetectedEncodings = options.detectEncodings.map(encoding => encoding.toLowerCase()); return lowerDetectedEncodings.includes(encoding.toLowerCase()); } From c5139e205bb5a7742d7788b9d947ac672fc0dd85 Mon Sep 17 00:00:00 2001 From: Luca Rath-Heel Date: Tue, 9 Apr 2024 13:44:40 +0200 Subject: [PATCH 2/2] Update dist files --- dist/jschardet.js | 2 +- dist/jschardet.min.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dist/jschardet.js b/dist/jschardet.js index 034dba3..df665b3 100644 --- a/dist/jschardet.js +++ b/dist/jschardet.js @@ -7579,7 +7579,7 @@ function UniversalDetector(options) { if (!options.detectEncodings) { return true; } - lowerDetectedEncodings = options.detectEncodings.map(encoding => encoding.toLowerCase()); + const lowerDetectedEncodings = options.detectEncodings.map(encoding => encoding.toLowerCase()); return lowerDetectedEncodings.includes(encoding.toLowerCase()); } diff --git a/dist/jschardet.min.js b/dist/jschardet.min.js index 2585bca..12ca4f4 100644 --- a/dist/jschardet.min.js +++ b/dist/jschardet.min.js @@ -660,13 +660,13 @@ this.reset=function(){c.prototype.reset.apply(this);this._mContextAnalyzer.reset d).join(""),d),this._mDistributionAnalyzer.feed(this._mLastChar.join(""),d)):(this._mContextAnalyzer.feed(a.slice(c+1-d,c+3-d),d),this._mDistributionAnalyzer.feed(a.slice(c-1,c+1),d)))}this._mLastChar[0]=a[b-1];this.getState()==h.detecting&&this._mContextAnalyzer.gotEnoughData()&&this.getConfidence()>h.SHORTCUT_THRESHOLD&&(this._mState=h.foundIt);return this.getState()};this.getConfidence=function(){var a=this._mContextAnalyzer.getConfidence(),b=this._mDistributionAnalyzer.getConfidence();return Math.max(a, b)};this._mCodingSM=new f(e);this._mDistributionAnalyzer=new l;this._mContextAnalyzer=new k;this.reset()}var f=a("./codingstatemachine"),g=a("./mbcharsetprober"),e=a("./mbcssm/sjis"),l=a("./chardistribution").SJISDistributionAnalysis,k=a("./jpcntx").SJISContextAnalysis,h=a("./constants"),m=a("./logger");c.prototype=new g;d.exports=c},{"./chardistribution":4,"./codingstatemachine":7,"./constants":8,"./jpcntx":21,"./logger":29,"./mbcharsetprober":30,"./mbcssm/sjis":37}],42:[function(a,d,b){var c=a("./constants"), f=a("./mbcsgroupprober"),g=a("./sbcsgroupprober"),e=a("./latin1prober"),l=a("./escprober"),k=a("./logger"),h=function(){for(var a=[new l,new f,new g,new e],b="UTF-8 UTF-32LE UTF-32BE UTF-32BE UTF-16LE UTF-16BE X-ISO-10646-UCS-4-3412 X-ISO-10646-UCS-4-2143".split(" ").slice(0),a=$jscomp.makeIterator(a),c=a.next();!c.done;c=a.next())[].push.apply(b,c.value.getSupportedCharsetNames());return b}(),m=function(){for(var a=[],b=$jscomp.makeIterator(h),c=b.next();!c.done;c=b.next())c=c.value,a.push(c.toLocaleLowerCase(), -c.toLocaleLowerCase().replace(/-/g,""));return a}();d.exports=function(a){function b(c){if(!a.detectEncodings)return!0;lowerDetectedEncodings=a.detectEncodings.map(function(a){return a.toLowerCase()});return lowerDetectedEncodings.includes(c.toLowerCase())}a||(a={});"number"!==typeof a.minimumThreshold&&(a.minimumThreshold=a.detectEncodings?0:.2);if(a.detectEncodings)for(var d=$jscomp.makeIterator(a.detectEncodings),n=d.next();!n.done;n=d.next())if(n=n.value,!m.includes(n.toLowerCase()))throw Error("Encoding "+ -n+" is not supported. Supported encodings: "+h+".");this.reset=function(){this.result={encoding:null,confidence:0};this.results=[];this.done=!1;this._mStart=!0;this._mGotData=!1;this._mInputState=0;this._mLastChar=[];this._mBOM="";this._mEscCharsetProber&&this._mEscCharsetProber.reset();for(var a=0,b;b=this._mCharsetProbers[a];a++)b.reset()};this.feed=function(a){if(!this.done&&a.length)if(this._mGotData||(this._mBOM+=a,"\u00ef\u00bb\u00bf"==this._mBOM.slice(0,3)&&b("UTF-8")?this.result={encoding:"UTF-8", -confidence:1}:"\u00ff\u00fe\x00\x00"==this._mBOM.slice(0,4)&&b("UTF-32LE")?this.result={encoding:"UTF-32LE",confidence:1}:"\x00\x00\u00fe\u00ff"==this._mBOM.slice(0,4)&&b("UTF-32BE")?this.result={encoding:"UTF-32BE",confidence:1}:"\u00fe\u00ff\x00\x00"==this._mBOM.slice(0,4)&&b("X-ISO-10646-UCS-4-3412")?this.result={encoding:"X-ISO-10646-UCS-4-3412",confidence:1}:"\x00\x00\u00ff\u00fe"==this._mBOM.slice(0,4)&&b("X-ISO-10646-UCS-4-2143")?this.result={encoding:"X-ISO-10646-UCS-4-2143",confidence:1}: -"\u00ff\u00fe"==this._mBOM.slice(0,2)&&b("UTF-16LE")?this.result={encoding:"UTF-16LE",confidence:1}:"\u00fe\u00ff"==this._mBOM.slice(0,2)&&b("UTF-16BE")&&(this.result={encoding:"UTF-16BE",confidence:1}),0=a.minimumThreshold))return this.result=c}if(k.enabled)for(k.log("no probers hit minimum threshhold\n"),c=0;d=this._mCharsetProbers[c];c++)d&&b(d.getCharsetName())&&k.log(d.getCharsetName()+" confidence = "+d.getConfidence()+ -"\n")}};this._highBitDetector=/[\x80-\xFF]/;this._escDetector=/(\x1B|~\{)/;this._mEscCharsetProber=null;this._mCharsetProbers=[];this.reset()}},{"./constants":8,"./escprober":9,"./latin1prober":28,"./logger":29,"./mbcsgroupprober":31,"./sbcsgroupprober":40}],43:[function(a,d,b){function c(){g.apply(this);this.reset=function(){c.prototype.reset.apply(this);this._mCodingSM.reset();this._mBasicAsciiLen=this._mFullLen=this._mMBCharLen=this._mNumOfMBChar=0};this.getCharsetName=function(){return"UTF-8"}; -this.feed=function(a){this._mFullLen+=a.length;for(var b=0,c;bc.charCodeAt(0)&&this._mBasicAsciiLen++)}this.getState()==e.detecting&&this.getConfidence()>e.SHORTCUT_THRESHOLD&&(this._mState=e.foundIt);return this.getState()}; -this.getConfidence=function(){var a=.99,b=0,c=this._mFullLen-this._mBasicAsciiLen;0this._mNumOfMBChar&&.6>=b?(a*=Math.pow(.5,this._mNumOfMBChar),1-a):a};this._mCodingSM=new f(l);this.reset()}var f=a("./codingstatemachine"),g=a("./charsetprober"),e=a("./constants"),l=a("./mbcssm/utf8");c.prototype=new g;d.exports=c},{"./charsetprober":6,"./codingstatemachine":7,"./constants":8,"./mbcssm/utf8":38}]},{},[1])(1)}); +c.toLocaleLowerCase().replace(/-/g,""));return a}();d.exports=function(a){function b(c){return a.detectEncodings?a.detectEncodings.map(function(a){return a.toLowerCase()}).includes(c.toLowerCase()):!0}a||(a={});"number"!==typeof a.minimumThreshold&&(a.minimumThreshold=a.detectEncodings?0:.2);if(a.detectEncodings)for(var d=$jscomp.makeIterator(a.detectEncodings),n=d.next();!n.done;n=d.next())if(n=n.value,!m.includes(n.toLowerCase()))throw Error("Encoding "+n+" is not supported. Supported encodings: "+ +h+".");this.reset=function(){this.result={encoding:null,confidence:0};this.results=[];this.done=!1;this._mStart=!0;this._mGotData=!1;this._mInputState=0;this._mLastChar=[];this._mBOM="";this._mEscCharsetProber&&this._mEscCharsetProber.reset();for(var a=0,b;b=this._mCharsetProbers[a];a++)b.reset()};this.feed=function(a){if(!this.done&&a.length)if(this._mGotData||(this._mBOM+=a,"\u00ef\u00bb\u00bf"==this._mBOM.slice(0,3)&&b("UTF-8")?this.result={encoding:"UTF-8",confidence:1}:"\u00ff\u00fe\x00\x00"== +this._mBOM.slice(0,4)&&b("UTF-32LE")?this.result={encoding:"UTF-32LE",confidence:1}:"\x00\x00\u00fe\u00ff"==this._mBOM.slice(0,4)&&b("UTF-32BE")?this.result={encoding:"UTF-32BE",confidence:1}:"\u00fe\u00ff\x00\x00"==this._mBOM.slice(0,4)&&b("X-ISO-10646-UCS-4-3412")?this.result={encoding:"X-ISO-10646-UCS-4-3412",confidence:1}:"\x00\x00\u00ff\u00fe"==this._mBOM.slice(0,4)&&b("X-ISO-10646-UCS-4-2143")?this.result={encoding:"X-ISO-10646-UCS-4-2143",confidence:1}:"\u00ff\u00fe"==this._mBOM.slice(0,2)&& +b("UTF-16LE")?this.result={encoding:"UTF-16LE",confidence:1}:"\u00fe\u00ff"==this._mBOM.slice(0,2)&&b("UTF-16BE")&&(this.result={encoding:"UTF-16BE",confidence:1}),0=a.minimumThreshold))return this.result=c}if(k.enabled)for(k.log("no probers hit minimum threshhold\n"),c=0;d=this._mCharsetProbers[c];c++)d&&b(d.getCharsetName())&&k.log(d.getCharsetName()+" confidence = "+d.getConfidence()+"\n")}};this._highBitDetector= +/[\x80-\xFF]/;this._escDetector=/(\x1B|~\{)/;this._mEscCharsetProber=null;this._mCharsetProbers=[];this.reset()}},{"./constants":8,"./escprober":9,"./latin1prober":28,"./logger":29,"./mbcsgroupprober":31,"./sbcsgroupprober":40}],43:[function(a,d,b){function c(){g.apply(this);this.reset=function(){c.prototype.reset.apply(this);this._mCodingSM.reset();this._mBasicAsciiLen=this._mFullLen=this._mMBCharLen=this._mNumOfMBChar=0};this.getCharsetName=function(){return"UTF-8"};this.feed=function(a){this._mFullLen+= +a.length;for(var b=0,c;bc.charCodeAt(0)&&this._mBasicAsciiLen++)}this.getState()==e.detecting&&this.getConfidence()>e.SHORTCUT_THRESHOLD&&(this._mState=e.foundIt);return this.getState()};this.getConfidence=function(){var a= +.99,b=0,c=this._mFullLen-this._mBasicAsciiLen;0this._mNumOfMBChar&&.6>=b?(a*=Math.pow(.5,this._mNumOfMBChar),1-a):a};this._mCodingSM=new f(l);this.reset()}var f=a("./codingstatemachine"),g=a("./charsetprober"),e=a("./constants"),l=a("./mbcssm/utf8");c.prototype=new g;d.exports=c},{"./charsetprober":6,"./codingstatemachine":7,"./constants":8,"./mbcssm/utf8":38}]},{},[1])(1)});