arnaucube
arnaucube/raspberryGPIOhtmlserverPublic Self-hosted repository
raspberryGPIOhtmlserver/node_modules/utf8/README.md
node_modules/utf8/README.mdRaw
  1# utf8.js [![Build status](https://travis-ci.org/mathiasbynens/utf8.js.png?branch=master)](https://travis-ci.org/mathiasbynens/utf8.js) [![Dependency status](https://gemnasium.com/mathiasbynens/utf8.js.png)](https://gemnasium.com/mathiasbynens/utf8.js)
  2
  3_utf8.js_ is a well-tested UTF-8 encoder/decoder written in JavaScript. Unlike many other JavaScript solutions, it is designed to be a _proper_ UTF-8 encoder/decoder: it can encode/decode any given Unicode code point, including astral symbols and unpaired surrogates.
  4
  5Feel free to fork if you see possible improvements!
  6
  7## Installation
  8
  9Via [npm](http://npmjs.org/):
 10
 11```bash
 12npm install utf8
 13```
 14
 15Via [Bower](http://bower.io/):
 16
 17```bash
 18bower install utf8
 19```
 20
 21Via [Component](https://github.com/component/component):
 22
 23```bash
 24component install mathiasbynens/utf8.js
 25```
 26
 27In a browser:
 28
 29```html
 30<script src="utf8.js"></script>
 31```
 32
 33In [Narwhal](http://narwhaljs.org/), [Node.js](http://nodejs.org/), and [RingoJS ≥ v0.8.0](http://ringojs.org/):
 34
 35```js
 36var utf8 = require('utf8');
 37```
 38
 39In [Rhino](http://www.mozilla.org/rhino/):
 40
 41```js
 42load('utf8.js');
 43```
 44
 45Using an AMD loader like [RequireJS](http://requirejs.org/):
 46
 47```js
 48require(
 49  {
 50    'paths': {
 51      'utf8': 'path/to/utf8'
 52    }
 53  },
 54  ['utf8'],
 55  function(utf8) {
 56    console.log(utf8);
 57  }
 58);
 59```
 60
 61## API
 62
 63### `utf8.encode(string)`
 64
 65Encodes any given JavaScript string (`string`) as UTF-8, and returns the UTF-8-encoded version of the string.
 66
 67```js
 68// U+00A9 COPYRIGHT SIGN; see http://codepoints.net/U+00A9
 69utf8.encode('\xA9');
 70// → '\xC2\xA9'
 71// U+10001 LINEAR B SYLLABLE B038 E; see http://codepoints.net/U+10001
 72utf8.encode('\uD800\uDC01');
 73// → '\xF0\x90\x80\x81'
 74```
 75
 76### `utf8.decode(byteString)`
 77
 78Encodes any given UTF-8-encoded string (`byteString`) as UTF-8, and returns the UTF-8-decoded version of the string. It throws an error when malformed UTF-8 is detected.
 79
 80```js
 81utf8.decode('\xC2\xA9');
 82// → '\xA9'
 83
 84utf8.decode('\xF0\x90\x80\x81');
 85// → '\uD800\uDC01'
 86// → U+10001 LINEAR B SYLLABLE B038 E
 87```
 88
 89### `utf8.version`
 90
 91A string representing the semantic version number.
 92
 93## Support
 94
 95utf8.js has been tested in at least Chrome 27-29, Firefox 3-22, Safari 4-6, Opera 10-12, IE 6-10, Node.js v0.10.0, Narwhal 0.3.2, RingoJS 0.8-0.9, PhantomJS 1.9.0, and Rhino 1.7RC4.
 96
 97## Unit tests & code coverage
 98
 99After cloning this repository, run `npm install` to install the dependencies needed for development and testing. You may want to install Istanbul _globally_ using `npm install istanbul -g`.
100
101Once that’s done, you can run the unit tests in Node using `npm test` or `node tests/tests.js`. To run the tests in Rhino, Ringo, Narwhal, PhantomJS, and web browsers as well, use `grunt test`.
102
103To generate [the code coverage report](http://rawgithub.com/mathiasbynens/utf8.js/master/coverage/utf8.js/utf8.js.html), use `grunt cover`.
104
105## FAQ
106
107### Why is the first release named v2.0.0? Haven’t you heard of [semantic versioning](http://semver.org/)?
108
109Long before utf8.js was created, the `utf8` module on npm was registered and used by another (slightly buggy) library. @ryanmcgrath was kind enough to give me access to the `utf8` package on npm when I told him about utf8.js. Since there has already been a v1.0.0 release of the old library, and to avoid breaking backwards compatibility with projects that rely on the `utf8` npm package, I decided the tag the first release of utf8.js as v2.0.0 and take it from there.
110
111## Author
112
113| [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](http://twitter.com/mathias "Follow @mathias on Twitter") |
114|---|
115| [Mathias Bynens](http://mathiasbynens.be/) |
116
117## License
118
119utf8.js is dual licensed under the [MIT](http://mths.be/mit) and [GPL](http://mths.be/gpl) licenses.