Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Encoding
  2. **encoding** is a simple wrapper around [node-iconv](https://github.com/bnoordhuis/node-iconv) and [iconv-lite](https://github.com/ashtuchkin/iconv-lite/) to convert strings from one encoding to another. If node-iconv is not available for some reason,
  3. iconv-lite will be used instead of it as a fallback.
  4. [![Build Status](https://secure.travis-ci.org/andris9/encoding.svg)](http://travis-ci.org/andris9/Nodemailer)
  5. [![npm version](https://badge.fury.io/js/encoding.svg)](http://badge.fury.io/js/encoding)
  6. ## Install
  7. Install through npm
  8. npm install encoding
  9. ## Usage
  10. Require the module
  11. var encoding = require("encoding");
  12. Convert with encoding.convert()
  13. var resultBuffer = encoding.convert(text, toCharset, fromCharset);
  14. Where
  15. * **text** is either a Buffer or a String to be converted
  16. * **toCharset** is the characterset to convert the string
  17. * **fromCharset** (*optional*, defaults to UTF-8) is the source charset
  18. Output of the conversion is always a Buffer object.
  19. Example
  20. var result = encoding.convert("ÕÄÖÜ", "Latin_1");
  21. console.log(result); //<Buffer d5 c4 d6 dc>
  22. ## iconv support
  23. By default only iconv-lite is bundled. If you need node-iconv support, you need to add it
  24. as an additional dependency for your project:
  25. ...,
  26. "dependencies":{
  27. "encoding": "*",
  28. "iconv": "*"
  29. },
  30. ...
  31. ## License
  32. **MIT**