
\begin{DoxyItemize}
\item No need for native code compilation. Quick to install, works on Windows and in sandboxed environments like \href{http://c9.io}{\texttt{ Cloud9}}.
\item Used in popular projects like \href{https://github.com/expressjs/body-parser}{\texttt{ Express.\+js (body\+\_\+parser)}}, \href{http://gruntjs.com/}{\texttt{ Grunt}}, \href{http://www.nodemailer.com/}{\texttt{ Nodemailer}}, \href{http://yeoman.io/}{\texttt{ Yeoman}} and others.
\item Faster than \href{https://github.com/bnoordhuis/node-iconv}{\texttt{ node-\/iconv}} (see below for performance comparison).
\item Intuitive encode/decode API, including Streaming support.
\item In-\/browser usage via \href{https://github.com/substack/node-browserify}{\texttt{ browserify}} or \href{https://webpack.js.org/}{\texttt{ webpack}} ($\sim$180kb gzip compressed with Buffer shim included).
\item Typescript \href{https://github.com/ashtuchkin/iconv-lite/blob/master/lib/index.d.ts}{\texttt{ type definition file}} included.
\item React Native is supported (need to install {\ttfamily stream} module to enable Streaming API).
\item License\+: MIT.
\end{DoxyItemize}

\href{https://npmjs.org/package/iconv-lite/}{\texttt{ }} ~\newline
 \href{https://travis-ci.org/ashtuchkin/iconv-lite}{\texttt{ }} \href{https://npmjs.org/package/iconv-lite/}{\texttt{ }} \href{https://npmjs.org/package/iconv-lite/}{\texttt{ }} \href{https://npmjs.org/package/iconv-lite/}{\texttt{ }}\hypertarget{md_sfcode_node_modules_iconv_lite_README_autotoc_md12580}{}\doxysection{Usage}\label{md_sfcode_node_modules_iconv_lite_README_autotoc_md12580}
\hypertarget{md_sfcode_node_modules_iconv_lite_README_autotoc_md12581}{}\doxysubsection{Basic API}\label{md_sfcode_node_modules_iconv_lite_README_autotoc_md12581}

\begin{DoxyCode}{0}
\DoxyCodeLine{var iconv = require('iconv-\/lite');}
\DoxyCodeLine{}
\DoxyCodeLine{// Convert from an encoded buffer to a js string.}
\DoxyCodeLine{str = iconv.decode(Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251');}
\DoxyCodeLine{}
\DoxyCodeLine{// Convert from a js string to an encoded buffer.}
\DoxyCodeLine{buf = iconv.encode("{}Sample input string"{}, 'win1251');}
\DoxyCodeLine{}
\DoxyCodeLine{// Check if encoding is supported}
\DoxyCodeLine{iconv.encodingExists("{}us-\/ascii"{}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_iconv_lite_README_autotoc_md12582}{}\doxysubsection{Streaming API}\label{md_sfcode_node_modules_iconv_lite_README_autotoc_md12582}

\begin{DoxyCode}{0}
\DoxyCodeLine{// Decode stream (from binary data stream to js strings)}
\DoxyCodeLine{http.createServer(function(req, res) \{}
\DoxyCodeLine{    var converterStream = iconv.decodeStream('win1251');}
\DoxyCodeLine{    req.pipe(converterStream);}
\DoxyCodeLine{}
\DoxyCodeLine{    converterStream.on('data', function(str) \{}
\DoxyCodeLine{        console.log(str); // Do something with decoded strings, chunk-\/by-\/chunk.}
\DoxyCodeLine{    \});}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{// Convert encoding streaming example}
\DoxyCodeLine{fs.createReadStream('file-\/in-\/win1251.txt')}
\DoxyCodeLine{    .pipe(iconv.decodeStream('win1251'))}
\DoxyCodeLine{    .pipe(iconv.encodeStream('ucs2'))}
\DoxyCodeLine{    .pipe(fs.createWriteStream('file-\/in-\/ucs2.txt'));}
\DoxyCodeLine{}
\DoxyCodeLine{// Sugar: all encode/decode streams have .collect(cb) method to accumulate data.}
\DoxyCodeLine{http.createServer(function(req, res) \{}
\DoxyCodeLine{    req.pipe(iconv.decodeStream('win1251')).collect(function(err, body) \{}
\DoxyCodeLine{        assert(typeof body == 'string');}
\DoxyCodeLine{        console.log(body); // full request body string}
\DoxyCodeLine{    \});}
\DoxyCodeLine{\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_iconv_lite_README_autotoc_md12583}{}\doxysection{Supported encodings}\label{md_sfcode_node_modules_iconv_lite_README_autotoc_md12583}

\begin{DoxyItemize}
\item All node.\+js native encodings\+: utf8, ucs2 / utf16-\/le, ascii, binary, base64, hex.
\item Additional unicode encodings\+: utf16, utf16-\/be, utf-\/7, utf-\/7-\/imap, utf32, utf32-\/le, and utf32-\/be.
\item All widespread singlebyte encodings\+: Windows 125x family, ISO-\/8859 family, IBM/\+DOS codepages, Macintosh family, KOI8 family, all others supported by iconv library. Aliases like \textquotesingle{}latin1\textquotesingle{}, \textquotesingle{}us-\/ascii\textquotesingle{} also supported.
\item All widespread multibyte encodings\+: CP932, CP936, CP949, CP950, GB2312, GBK, GB18030, Big5, Shift\+\_\+\+JIS, EUC-\/\+JP.
\end{DoxyItemize}

See \href{https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings}{\texttt{ all supported encodings on wiki}}.

Most singlebyte encodings are generated automatically from \href{https://github.com/bnoordhuis/node-iconv}{\texttt{ node-\/iconv}}. Thank you Ben Noordhuis and libiconv authors!

Multibyte encodings are generated from \href{http://www.unicode.org/Public/MAPPINGS/}{\texttt{ Unicode.\+org mappings}} and \href{http://encoding.spec.whatwg.org/}{\texttt{ WHATWG Encoding Standard mappings}}. Thank you, respective authors!\hypertarget{md_sfcode_node_modules_iconv_lite_README_autotoc_md12584}{}\doxysection{Encoding/decoding speed}\label{md_sfcode_node_modules_iconv_lite_README_autotoc_md12584}
Comparison with node-\/iconv module (1000x256kb, on Mac\+Book Pro, Core i5/2.\+6 GHz, Node v0.\+12.\+0). Note\+: your results may vary, so please always check on your hardware. \begin{DoxyVerb}operation             iconv@2.1.4   iconv-lite@0.4.7
----------------------------------------------------------
encode('win1251')     ~96 Mb/s      ~320 Mb/s
decode('win1251')     ~95 Mb/s      ~246 Mb/s
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_iconv_lite_README_autotoc_md12585}{}\doxysection{BOM handling}\label{md_sfcode_node_modules_iconv_lite_README_autotoc_md12585}

\begin{DoxyItemize}
\item Decoding\+: BOM is stripped by default, unless overridden by passing {\ttfamily strip\+BOM\+: false} in options (f.\+ex. {\ttfamily iconv.\+decode(buf, enc, \{strip\+BOM\+: false\})}). A callback might also be given as a {\ttfamily strip\+BOM} parameter -\/ it\textquotesingle{}ll be called if BOM character was actually found.
\item If you want to detect UTF-\/8 BOM when decoding other encodings, use \href{https://github.com/danielgindi/node-autodetect-decoder-stream}{\texttt{ node-\/autodetect-\/decoder-\/stream}} module.
\item Encoding\+: No BOM added, unless overridden by {\ttfamily add\+BOM\+: true} option.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_iconv_lite_README_autotoc_md12586}{}\doxysection{UTF-\/16 Encodings}\label{md_sfcode_node_modules_iconv_lite_README_autotoc_md12586}
This library supports UTF-\/16\+LE, UTF-\/16\+BE and UTF-\/16 encodings. First two are straightforward, but UTF-\/16 is trying to be smart about endianness in the following ways\+:
\begin{DoxyItemize}
\item Decoding\+: uses BOM and \textquotesingle{}spaces heuristic\textquotesingle{} to determine input endianness. Default is UTF-\/16\+LE, but can be overridden with `default\+Encoding\+: \textquotesingle{}utf-\/16be'{\ttfamily option. Strips BOM unless}strip\+BOM\+: false{\ttfamily .}
\item {\ttfamily Encoding\+: uses UTF-\/16\+LE and writes BOM by default. Use}add\+BOM\+: false\`{} to override.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_iconv_lite_README_autotoc_md12587}{}\doxysection{UTF-\/32 Encodings}\label{md_sfcode_node_modules_iconv_lite_README_autotoc_md12587}
This library supports UTF-\/32\+LE, UTF-\/32\+BE and UTF-\/32 encodings. Like the UTF-\/16 encoding above, UTF-\/32 defaults to UTF-\/32\+LE, but uses BOM and \textquotesingle{}spaces heuristics\textquotesingle{} to determine input endianness.
\begin{DoxyItemize}
\item The default of UTF-\/32\+LE can be overridden with the `default\+Encoding\+: \textquotesingle{}utf-\/32be'{\ttfamily option. Strips BOM unless}strip\+BOM\+: false{\ttfamily .}
\item {\ttfamily Encoding\+: uses UTF-\/32\+LE and writes BOM by default. Use}add\+BOM\+: false{\ttfamily to override. (}default\+Encoding\+: \textquotesingle{}utf-\/32be\textquotesingle{}\`{} can also be used here to change encoding.)
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_iconv_lite_README_autotoc_md12588}{}\doxysection{Other notes}\label{md_sfcode_node_modules_iconv_lite_README_autotoc_md12588}
When decoding, be sure to supply a Buffer to decode() method, otherwise \href{https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding}{\texttt{ bad things usually happen}}. ~\newline
 Untranslatable characters are set to {\ucr} or ?. No transliteration is currently supported. ~\newline
 Node versions 0.\+10.\+31 and 0.\+11.\+13 are buggy, don\textquotesingle{}t use them (see \#65, \#77). ~\newline
\hypertarget{md_sfcode_node_modules_iconv_lite_README_autotoc_md12589}{}\doxysection{Testing}\label{md_sfcode_node_modules_iconv_lite_README_autotoc_md12589}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ git clone git@github.com:ashtuchkin/iconv-\/lite.git}
\DoxyCodeLine{\$ cd iconv-\/lite}
\DoxyCodeLine{\$ npm install}
\DoxyCodeLine{\$ npm test}
\DoxyCodeLine{    }
\DoxyCodeLine{\$ \# To view performance:}
\DoxyCodeLine{\$ node test/performance.js}
\DoxyCodeLine{}
\DoxyCodeLine{\$ \# To view test coverage:}
\DoxyCodeLine{\$ npm run coverage}
\DoxyCodeLine{\$ open coverage/lcov-\/report/index.html }

\end{DoxyCode}
 