@@ -84,6 +84,12 @@ export const THEME_OPTIONS: { label: string; value: string; dark: boolean }[] =
8484 { label : 'High Contrast Black(深色模式)' , value : 'hc-black' , dark : true } ,
8585]
8686
87+ const codeMatch = ( v : string ) => {
88+ const sum = v . length
89+ const err = v . split ( '' ) . filter ( ( i ) => i . charCodeAt ( 0 ) > 191 ) . length
90+ return err / sum < 0.1
91+ }
92+
8793export const ENCODING_OPTIONS = [
8894 // 推荐优先显示(常用编码)
8995 { value : 'utf-8' , label : 'UTF-8' } ,
@@ -96,29 +102,13 @@ export const ENCODING_OPTIONS = [
96102 { value : 'utf-16le' , label : 'UTF-16 LE' } ,
97103 { value : 'utf-16be' , label : 'UTF-16 BE' } ,
98104 { value : 'utf-16' , label : 'UTF-16' } ,
99- { value : 'ascii' , label : 'ASCII' } ,
100- { value : 'latin1' , label : 'ISO-8859-1' } ,
101- { value : 'windows-1252' , label : 'Windows-1252' } ,
105+ { value : 'ascii' , label : 'ASCII' , match : codeMatch } ,
106+ { value : 'latin1' , label : 'ISO-8859-1' , match : codeMatch } ,
107+ { value : 'windows-1252' , label : 'Windows-1252' , match : codeMatch } ,
102108
103109 // 日韩编码
104110 { value : 'shift_jis' , label : 'Shift_JIS' } ,
105111 { value : 'euc-jp' , label : 'EUC-JP' } ,
106112 { value : 'euc-kr' , label : 'EUC-KR' } ,
107113 { value : 'windows-949' , label : 'Windows-949' } ,
108-
109- // 东欧/斯拉夫编码
110- { value : 'windows-1251' , label : 'Windows-1251' } ,
111- { value : 'koi8-r' , label : 'KOI8-R' } ,
112- { value : 'iso-8859-5' , label : 'ISO-8859-5' } ,
113-
114- // 西欧/南欧编码
115- { value : 'iso-8859-2' , label : 'ISO-8859-2' } ,
116- { value : 'windows-1250' , label : 'Windows-1250' } ,
117- { value : 'iso-8859-3' , label : 'ISO-8859-3' } ,
118-
119- // 中东编码
120- { value : 'windows-1256' , label : 'Windows-1256' } ,
121- { value : 'iso-8859-6' , label : 'ISO-8859-6' } ,
122- { value : 'windows-1255' , label : 'Windows-1255' } ,
123- { value : 'iso-8859-8' , label : 'ISO-8859-8' } ,
124114]
0 commit comments