Ein Projekt das es ermöglicht Beerpong über das Internet von zwei unabhängigen positionen aus zu spielen. Entstehung im Rahmen einer Praktikumsaufgabe im Fach Interaktion.
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 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. ## Pure JS character encoding conversion
  2. <!-- [![Build Status](https://secure.travis-ci.org/ashtuchkin/iconv-lite.png?branch=master)](http://travis-ci.org/ashtuchkin/iconv-lite) -->
  3. * Doesn't need native code compilation. Works on Windows and in sandboxed environments like [Cloud9](http://c9.io).
  4. * Used in popular projects like [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
  7. * Streaming support for Node v0.10+
  8. * Can extend Node.js primitives (buffers, streams) to support all iconv-lite encodings.
  9. * In-browser usage via [Browserify](https://github.com/substack/node-browserify) (~180k gzip compressed with Buffer shim included).
  10. * License: MIT.
  11. [![NPM Stats](https://nodei.co/npm/iconv-lite.png?downloads=true)](https://npmjs.org/packages/iconv-lite/)
  12. ## Usage
  13. ### Basic API
  14. ```javascript
  15. var iconv = require('iconv-lite');
  16. // Convert from an encoded buffer to js string.
  17. str = iconv.decode(new Buffer([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251');
  18. // Convert from js string to an encoded buffer.
  19. buf = iconv.encode("Sample input string", 'win1251');
  20. // Check if encoding is supported
  21. iconv.encodingExists("us-ascii")
  22. ```
  23. ### Streaming API (Node v0.10+)
  24. ```javascript
  25. // Decode stream (from binary stream to js strings)
  26. http.createServer(function(req, res) {
  27. var converterStream = iconv.decodeStream('win1251');
  28. req.pipe(converterStream);
  29. converterStream.on('data', function(str) {
  30. console.log(str); // Do something with decoded strings, chunk-by-chunk.
  31. });
  32. });
  33. // Convert encoding streaming example
  34. fs.createReadStream('file-in-win1251.txt')
  35. .pipe(iconv.decodeStream('win1251'))
  36. .pipe(iconv.encodeStream('ucs2'))
  37. .pipe(fs.createWriteStream('file-in-ucs2.txt'));
  38. // Sugar: all encode/decode streams have .collect(cb) method to accumulate data.
  39. http.createServer(function(req, res) {
  40. req.pipe(iconv.decodeStream('win1251')).collect(function(err, body) {
  41. assert(typeof body == 'string');
  42. console.log(body); // full request body string
  43. });
  44. });
  45. ```
  46. ### Extend Node.js own encodings
  47. ```javascript
  48. // After this call all Node basic primitives will understand iconv-lite encodings.
  49. iconv.extendNodeEncodings();
  50. // Examples:
  51. buf = new Buffer(str, 'win1251');
  52. buf.write(str, 'gbk');
  53. str = buf.toString('latin1');
  54. assert(Buffer.isEncoding('iso-8859-15'));
  55. Buffer.byteLength(str, 'us-ascii');
  56. http.createServer(function(req, res) {
  57. req.setEncoding('big5');
  58. req.collect(function(err, body) {
  59. console.log(body);
  60. });
  61. });
  62. fs.createReadStream("file.txt", "shift_jis");
  63. // External modules are also supported (if they use Node primitives, which they probably do).
  64. request = require('request');
  65. request({
  66. url: "http://github.com/",
  67. encoding: "cp932"
  68. });
  69. // To remove extensions
  70. iconv.undoExtendNodeEncodings();
  71. ```
  72. ## Supported encodings
  73. * All node.js native encodings: utf8, ucs2 / utf16-le, ascii, binary, base64, hex.
  74. * Additional unicode encodings: utf16, utf16-be, utf-7, utf-7-imap.
  75. * All widespread singlebyte encodings: Windows 125x family, ISO-8859 family,
  76. IBM/DOS codepages, Macintosh family, KOI8 family, all others supported by iconv library.
  77. Aliases like 'latin1', 'us-ascii' also supported.
  78. * All widespread multibyte encodings: CP932, CP936, CP949, CP950, GB2313, GBK, GB18030, Big5, Shift_JIS, EUC-JP.
  79. See [all supported encodings on wiki](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings).
  80. Most singlebyte encodings are generated automatically from [node-iconv](https://github.com/bnoordhuis/node-iconv). Thank you Ben Noordhuis and libiconv authors!
  81. 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!
  82. ## Encoding/decoding speed
  83. Comparison with node-iconv module (1000x256kb, on MacBook Pro, Core i5/2.6 GHz, Node v0.10.26).
  84. Note: your results may vary, so please always check on your hardware.
  85. operation iconv@2.1.4 iconv-lite@0.4.0
  86. ----------------------------------------------------------
  87. encode('win1251') ~130 Mb/s ~380 Mb/s
  88. decode('win1251') ~127 Mb/s ~210 Mb/s
  89. ## Notes
  90. 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).
  91. Untranslatable characters are set to � or ?. No transliteration is currently supported.
  92. ## Testing
  93. ```bash
  94. $ git clone git@github.com:ashtuchkin/iconv-lite.git
  95. $ cd iconv-lite
  96. $ npm install
  97. $ npm test
  98. $ # To view performance:
  99. $ node test/performance.js
  100. ```
  101. ## Adoption
  102. [![NPM](https://nodei.co/npm-dl/iconv-lite.png)](https://nodei.co/npm/iconv-lite/)