Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. ## iconv-lite: Pure JS character encoding conversion
  2. * No need for native code compilation. Quick to install, works on Windows and in sandboxed environments like [Cloud9](http://c9.io).
  3. * Used in popular projects like [Express.js (body_parser)](https://github.com/expressjs/body-parser),
  4. [Grunt](http://gruntjs.com/), [Nodemailer](http://www.nodemailer.com/), [Yeoman](http://yeoman.io/) and others.
  5. * Faster than [node-iconv](https://github.com/bnoordhuis/node-iconv) (see below for performance comparison).
  6. * Intuitive encode/decode API, including Streaming support.
  7. * In-browser usage via [browserify](https://github.com/substack/node-browserify) or [webpack](https://webpack.js.org/) (~180kb gzip compressed with Buffer shim included).
  8. * Typescript [type definition file](https://github.com/ashtuchkin/iconv-lite/blob/master/lib/index.d.ts) included.
  9. * React Native is supported (need to install `stream` module to enable Streaming API).
  10. * License: MIT.
  11. [![NPM Stats](https://nodei.co/npm/iconv-lite.png)](https://npmjs.org/package/iconv-lite/)
  12. [![Build Status](https://travis-ci.org/ashtuchkin/iconv-lite.svg?branch=master)](https://travis-ci.org/ashtuchkin/iconv-lite)
  13. [![npm](https://img.shields.io/npm/v/iconv-lite.svg)](https://npmjs.org/package/iconv-lite/)
  14. [![npm downloads](https://img.shields.io/npm/dm/iconv-lite.svg)](https://npmjs.org/package/iconv-lite/)
  15. [![npm bundle size](https://img.shields.io/bundlephobia/min/iconv-lite.svg)](https://npmjs.org/package/iconv-lite/)
  16. ## Usage
  17. ### Basic API
  18. ```javascript
  19. var iconv = require('iconv-lite');
  20. // Convert from an encoded buffer to a js string.
  21. str = iconv.decode(Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251');
  22. // Convert from a js string to an encoded buffer.
  23. buf = iconv.encode("Sample input string", 'win1251');
  24. // Check if encoding is supported
  25. iconv.encodingExists("us-ascii")
  26. ```
  27. ### Streaming API
  28. ```javascript
  29. // Decode stream (from binary data stream to js strings)
  30. http.createServer(function(req, res) {
  31. var converterStream = iconv.decodeStream('win1251');
  32. req.pipe(converterStream);
  33. converterStream.on('data', function(str) {
  34. console.log(str); // Do something with decoded strings, chunk-by-chunk.
  35. });
  36. });
  37. // Convert encoding streaming example
  38. fs.createReadStream('file-in-win1251.txt')
  39. .pipe(iconv.decodeStream('win1251'))
  40. .pipe(iconv.encodeStream('ucs2'))
  41. .pipe(fs.createWriteStream('file-in-ucs2.txt'));
  42. // Sugar: all encode/decode streams have .collect(cb) method to accumulate data.
  43. http.createServer(function(req, res) {
  44. req.pipe(iconv.decodeStream('win1251')).collect(function(err, body) {
  45. assert(typeof body == 'string');
  46. console.log(body); // full request body string
  47. });
  48. });
  49. ```
  50. ## Supported encodings
  51. * All node.js native encodings: utf8, ucs2 / utf16-le, ascii, binary, base64, hex.
  52. * Additional unicode encodings: utf16, utf16-be, utf-7, utf-7-imap, utf32, utf32-le, and utf32-be.
  53. * All widespread singlebyte encodings: Windows 125x family, ISO-8859 family,
  54. IBM/DOS codepages, Macintosh family, KOI8 family, all others supported by iconv library.
  55. Aliases like 'latin1', 'us-ascii' also supported.
  56. * All widespread multibyte encodings: CP932, CP936, CP949, CP950, GB2312, GBK, GB18030, Big5, Shift_JIS, EUC-JP.
  57. See [all supported encodings on wiki](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).
  58. Most singlebyte encodings are generated automatically from [node-iconv](https://github.com/bnoordhuis/node-iconv). Thank you Ben Noordhuis and libiconv authors!
  59. Multibyte encodings are generated from [Unicode.org mappings](http://www.unicode.org/Public/MAPPINGS/) and [WHATWG Encoding Standard mappings](http://encoding.spec.whatwg.org/). Thank you, respective authors!
  60. ## Encoding/decoding speed
  61. Comparison with node-iconv module (1000x256kb, on MacBook Pro, Core i5/2.6 GHz, Node v0.12.0).
  62. Note: your results may vary, so please always check on your hardware.
  63. operation iconv@2.1.4 iconv-lite@0.4.7
  64. ----------------------------------------------------------
  65. encode('win1251') ~96 Mb/s ~320 Mb/s
  66. decode('win1251') ~95 Mb/s ~246 Mb/s
  67. ## BOM handling
  68. * Decoding: BOM is stripped by default, unless overridden by passing `stripBOM: false` in options
  69. (f.ex. `iconv.decode(buf, enc, {stripBOM: false})`).
  70. A callback might also be given as a `stripBOM` parameter - it'll be called if BOM character was actually found.
  71. * If you want to detect UTF-8 BOM when decoding other encodings, use [node-autodetect-decoder-stream](https://github.com/danielgindi/node-autodetect-decoder-stream) module.
  72. * Encoding: No BOM added, unless overridden by `addBOM: true` option.
  73. ## UTF-16 Encodings
  74. This library supports UTF-16LE, UTF-16BE and UTF-16 encodings. First two are straightforward, but UTF-16 is trying to be
  75. smart about endianness in the following ways:
  76. * Decoding: uses BOM and 'spaces heuristic' to determine input endianness. Default is UTF-16LE, but can be
  77. overridden with `defaultEncoding: 'utf-16be'` option. Strips BOM unless `stripBOM: false`.
  78. * Encoding: uses UTF-16LE and writes BOM by default. Use `addBOM: false` to override.
  79. ## UTF-32 Encodings
  80. This library supports UTF-32LE, UTF-32BE and UTF-32 encodings. Like the UTF-16 encoding above, UTF-32 defaults to UTF-32LE, but uses BOM and 'spaces heuristics' to determine input endianness.
  81. * The default of UTF-32LE can be overridden with the `defaultEncoding: 'utf-32be'` option. Strips BOM unless `stripBOM: false`.
  82. * Encoding: uses UTF-32LE and writes BOM by default. Use `addBOM: false` to override. (`defaultEncoding: 'utf-32be'` can also be used here to change encoding.)
  83. ## Other notes
  84. When decoding, be sure to supply a Buffer to decode() method, otherwise [bad things usually happen](https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding).
  85. Untranslatable characters are set to � or ?. No transliteration is currently supported.
  86. Node versions 0.10.31 and 0.11.13 are buggy, don't use them (see #65, #77).
  87. ## Testing
  88. ```bash
  89. $ git clone git@github.com:ashtuchkin/iconv-lite.git
  90. $ cd iconv-lite
  91. $ npm install
  92. $ npm test
  93. $ # To view performance:
  94. $ node test/performance.js
  95. $ # To view test coverage:
  96. $ npm run coverage
  97. $ open coverage/lcov-report/index.html
  98. ```