提交 a2af83d5 编写于 作者: K katainaka0503

Introduce minimum threshold

上级 e1a43609
...@@ -4,4 +4,8 @@ declare module 'jschardet' { ...@@ -4,4 +4,8 @@ declare module 'jschardet' {
confidence: number confidence: number
} }
export function detect(buffer: NodeBuffer): IDetectedMap; export function detect(buffer: NodeBuffer): IDetectedMap;
export const Constants: {
MINIMUM_THRESHOLD: number,
}
} }
\ No newline at end of file
...@@ -95,7 +95,11 @@ export function detectEncodingByBOM(file: string): TPromise<string> { ...@@ -95,7 +95,11 @@ export function detectEncodingByBOM(file: string): TPromise<string> {
return stream.readExactlyByFile(file, 3).then(({ buffer, bytesRead }) => detectEncodingByBOMFromBuffer(buffer, bytesRead)); return stream.readExactlyByFile(file, 3).then(({ buffer, bytesRead }) => detectEncodingByBOMFromBuffer(buffer, bytesRead));
} }
const MINIMUM_THRESHOLD = 0.2; //Todo. Decide how much this should be.
const IGNORE_ENCODINGS = ['ascii', 'utf-8', 'utf-16', 'utf-32']; const IGNORE_ENCODINGS = ['ascii', 'utf-8', 'utf-16', 'utf-32'];
jschardet.Constants.MINIMUM_THRESHOLD = MINIMUM_THRESHOLD;
/** /**
* Guesses the encoding from buffer. * Guesses the encoding from buffer.
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册