char-encoding-detector
Advanced tools
Comparing version
import { Options, IMatch } from './type'; | ||
/** | ||
* Returns the most probable encoding or the list matching encoding ordered by confidence if { allMatches: true } | ||
* is set in opts parameter. | ||
*/ | ||
export declare function detectEncoding(buffer: Uint8Array, opts?: Options): IMatch[] | string; | ||
/** | ||
* Returns the character encoding with the highest confidence | ||
*/ | ||
export declare function detectMostProbableEncoding(buffer: Uint8Array): string; | ||
/** | ||
* Returns an array of possible character encodings ordered by confidence. | ||
*/ | ||
export declare function detectAllPossibleEncodings(buffer: Uint8Array): IMatch[]; | ||
/** | ||
* Reads the file and returns the character encoding with the highest confidence or | ||
* array of possible character encodings ordered by confidence if { allMatches: true } | ||
* is set in opts parameter. | ||
*/ | ||
export declare function detectFileEncoding(file: File, opts?: Options): Promise<string | IMatch[]>; | ||
/** | ||
* Reads the file and returns the character encoding with the highest confidence. | ||
*/ | ||
export declare function detectFileMostProbableEncoding(file: File): Promise<string>; | ||
/** | ||
* Reads the file and returns array of possible character encodings ordered by confidence. | ||
*/ | ||
export declare function detectFileAllPossibleEncodings(file: File): Promise<IMatch[]>; |
{ | ||
"name": "char-encoding-detector", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"homepage": "https://github.com/GlobalSport/char-encoding-detector", | ||
@@ -5,0 +5,0 @@ "description": "Character encoding detector", |
@@ -5,3 +5,6 @@  | ||
Port of [node-chardet](https://github.com/runk/node-chardet) in pure JavaScript without NodeJS specific code. | ||
Port of [node-chardet](https://github.com/runk/node-chardet) in pure JavaScript without NodeJS specific API, ie. it can be used in browser. | ||
===== | ||
Module is based on ICU project http://site.icu-project.org/, which uses character | ||
@@ -25,6 +28,8 @@ occurrence analysis to determine the most probable encoding. | ||
```javascript | ||
import { detectEncoding, detectFileEncoding } from 'char-encoding-detector'; | ||
detectEncoding(uint8Array); | ||
import { detectMostProbableEncoding, detectFileMostProbableEncoding } from 'char-encoding-detector'; | ||
const encoding = detectMostProbableEncoding(uint8Array); | ||
// or | ||
detectFileEncoding(file).then((encoding) => {}); | ||
detectFileMostProbableEncoding(file).then((encodings) => {}); | ||
``` | ||
@@ -35,7 +40,9 @@ | ||
```javascript | ||
import { detectEncoding, detectFileEncoding } from 'char-encoding-detector'; | ||
import { detectAllPossibleEncodings, detectFileAllPossibleEncodings } from 'char-encoding-detector'; | ||
detectEncoding(uint8Array, { allMatches: true }); | ||
const encodings = detectAllPossibleEncodings(uint8Array); | ||
// or | ||
detectFileEncoding(file, { allMatches: true }); | ||
detectFileAllPossibleEncodings(file).then((encodings) => {}); | ||
``` | ||
@@ -42,0 +49,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
524931
1.49%3368
3.28%81
9.46%