Chardet is a character detection module for Node\+JS written in pure Javascript. Module is based on ICU project \href{http://site.icu-project.org/}{\texttt{ http\+://site.\+icu-\/project.\+org/}}, which uses character occurency analysis to determine the most probable encoding.\hypertarget{md_sfcode_node_modules_chardet_README_autotoc_md5061}{}\doxysection{Installation}\label{md_sfcode_node_modules_chardet_README_autotoc_md5061}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm i chardet }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_chardet_README_autotoc_md5062}{}\doxysection{Usage}\label{md_sfcode_node_modules_chardet_README_autotoc_md5062}
To return the encoding with the highest confidence\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{var chardet = require('chardet');}
\DoxyCodeLine{chardet.detect(Buffer.alloc('hello there!'));}
\DoxyCodeLine{// or}
\DoxyCodeLine{chardet.detectFile('/path/to/file', function(err, encoding) \{\});}
\DoxyCodeLine{// or}
\DoxyCodeLine{chardet.detectFileSync('/path/to/file'); }

\end{DoxyCode}


To return the full list of possible encodings\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{var chardet = require('chardet');}
\DoxyCodeLine{chardet.detectAll(Buffer.alloc('hello there!'));}
\DoxyCodeLine{// or}
\DoxyCodeLine{chardet.detectFileAll('/path/to/file', function(err, encoding) \{\});}
\DoxyCodeLine{// or}
\DoxyCodeLine{chardet.detectFileAllSync('/path/to/file');}
\DoxyCodeLine{}
\DoxyCodeLine{//Returned value is an array of objects sorted by confidence value in decending order}
\DoxyCodeLine{//e.g. [\{ confidence: 90, name: 'UTF-\/8'\}, \{confidence: 20, name: 'windows-\/1252', lang: 'fr'\}] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_chardet_README_autotoc_md5063}{}\doxysection{Working with large data sets}\label{md_sfcode_node_modules_chardet_README_autotoc_md5063}
Sometimes, when data set is huge and you want to optimize performace (in tradeoff of less accuracy), you can sample only first N bytes of the buffer\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{chardet.detectFile('/path/to/file', \{ sampleSize: 32 \}, function(err, encoding) \{\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_chardet_README_autotoc_md5064}{}\doxysection{Supported Encodings\+:}\label{md_sfcode_node_modules_chardet_README_autotoc_md5064}

\begin{DoxyItemize}
\item UTF-\/8
\item UTF-\/16 LE
\item UTF-\/16 BE
\item UTF-\/32 LE
\item UTF-\/32 BE
\item ISO-\/2022-\/\+JP
\item ISO-\/2022-\/\+KR
\item ISO-\/2022-\/\+CN
\item Shift-\/\+JIS
\item Big5
\item EUC-\/\+JP
\item EUC-\/\+KR
\item GB18030
\item ISO-\/8859-\/1
\item ISO-\/8859-\/2
\item ISO-\/8859-\/5
\item ISO-\/8859-\/6
\item ISO-\/8859-\/7
\item ISO-\/8859-\/8
\item ISO-\/8859-\/9
\item windows-\/1250
\item windows-\/1251
\item windows-\/1252
\item windows-\/1253
\item windows-\/1254
\item windows-\/1255
\item windows-\/1256
\item KOI8-\/R
\end{DoxyItemize}

Currently only these encodings are supported, more will be added soon. 