Commit 34edcca 1 parent 33e22e0 commit 34edcca Copy full SHA for 34edcca
File tree 3 files changed +35
-1
lines changed
3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 49
49
"watch:css" : " yarn run build:css -w"
50
50
},
51
51
"dependencies" : {
52
+ "chardet" : " ^0.8.0" ,
52
53
"dayjs" : " ^1.8.20" ,
53
54
"minimatch" : " ^3.0.4" ,
54
55
"original-fs" : " ^1.0.0" ,
59
60
"devDependencies" : {
60
61
"@semantic-release/changelog" : " ^5.0.0" ,
61
62
"@semantic-release/git" : " ^9.0.0" ,
63
+ "@types/chardet" : " ^0.8.0" ,
62
64
"@types/glob" : " ^7.1.1" ,
63
65
"@types/mocha" : " ^7.0.0" ,
64
66
"@types/node" : " ^12.11.7" ,
1246
1248
"type" : " boolean" ,
1247
1249
"description" : " Set to ignore externals definitions on update (add --ignore-externals)" ,
1248
1250
"default" : true
1251
+ },
1252
+ "svn.experimental.detect_encoding" : {
1253
+ "type" : " boolean" ,
1254
+ "description" : " Try the experimental encoding detection" ,
1255
+ "default" : false
1249
1256
}
1250
1257
}
1251
1258
}
Original file line number Diff line number Diff line change 1
1
import { jschardet } from "./vscodeModules" ;
2
+ import * as chardet from "chardet" ;
3
+ import { configuration } from "./helpers/configuration" ;
2
4
3
5
if ( jschardet . Constants ) {
4
6
jschardet . Constants . MINIMUM_THRESHOLD = 0.2 ;
@@ -51,7 +53,20 @@ export function detectEncoding(buffer: Buffer): string | null {
51
53
return result ;
52
54
}
53
55
54
- const detected = jschardet . detect ( buffer ) ;
56
+ const experimental = configuration . get < boolean > (
57
+ "experimental.detect_encoding" ,
58
+ false
59
+ ) ;
60
+ if ( experimental ) {
61
+ const detected = chardet . detect ( buffer ) ;
62
+ if ( detected ) {
63
+ return detected . replace ( / [ ^ a - z A - Z 0 - 9 ] / g, "" ) . toLocaleLowerCase ( ) ;
64
+ }
65
+
66
+ return null ;
67
+ }
68
+
69
+ const detected = jschardet . detect ( buffer . slice ( 0 , 512 * 128 ) ) ; // ensure to limit buffer for guessing due to https://github.com/aadsm/jschardet/issues/53
55
70
56
71
if ( ! detected || ! detected . encoding || detected . confidence < 0.8 ) {
57
72
return null ;
Original file line number Diff line number Diff line change 247
247
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.0.0.tgz#9c13c2574c92d4503b005feca8f2e16cc1611506"
248
248
integrity sha512-KYyTT/T6ALPkIRd2Ge080X/BsXvy9O0hcWTtMWkPvwAwF99+vn6Dv4GzrFT/Nn1LePr+FFDbRXXlqmsy9lw2zA==
249
249
250
+ " @types/chardet@^0.8.0 " :
251
+ version "0.8.0"
252
+ resolved "https://registry.yarnpkg.com/@types/chardet/-/chardet-0.8.0.tgz#40932a9d751bb1ff22e7403312faaf81755ad432"
253
+ integrity sha512-0PFX0r+bt2W6np4tZzF2Gh28pPLTM7lgjLMs0DJnV/Y4rPI3kLJCwtwRTb4aGl1iHmuF8TEmizzfJOw/7XQRfw==
254
+ dependencies :
255
+ " @types/node" " *"
256
+
250
257
" @types/color-name@^1.1.1 " :
251
258
version "1.1.1"
252
259
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
@@ -901,6 +908,11 @@ chardet@^0.7.0:
901
908
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
902
909
integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==
903
910
911
+ chardet@^0.8.0 :
912
+ version "0.8.0"
913
+ resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.8.0.tgz#215e9e457296aa88fb0c38b010fd7a7e20482ed3"
914
+ integrity sha512-fRAe54sDSPvCz9I3puKUoUpLBEIUjlwBoNyNcD2eAiP5Ybw2iXnrT7w15hfkNywosXFNllWwvOKsxl7UUCKQaQ==
915
+
904
916
cheerio@^1.0.0-rc.1 :
905
917
version "1.0.0-rc.3"
906
918
resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.3.tgz#094636d425b2e9c0f4eb91a46c05630c9a1a8bf6"
You can’t perform that action at this time.
0 commit comments