btoa.js/README.md

41 lines
982 B
Markdown
Raw Permalink Normal View History

2012-09-19 14:22:55 -06:00
btoa
===
2018-03-27 22:44:53 -06:00
| [atob](https://git.coolaj86.com/coolaj86/atob.js)
| **btoa**
| [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js)
| Sponsored by [ppl](https://ppl.family)
2013-07-25 10:01:20 -07:00
A port of the browser's `btoa` function.
2018-03-27 22:44:53 -06:00
Uses `Buffer` to emulate the exact functionality of the browser's btoa
(except that it supports some unicode that the browser may not).
2012-09-19 14:22:55 -06:00
2014-05-20 09:58:09 -05:00
It turns <strong>b</strong>inary data __to__ base64-encoded <strong>a</strong>scii.
2012-09-19 14:22:55 -06:00
2018-03-27 22:44:53 -06:00
```js
(function () {
"use strict";
var btoa = require('btoa');
var bin = "Hello, 世界";
var b64 = btoa(bin);
2012-09-19 14:22:55 -06:00
2018-03-27 22:44:53 -06:00
console.log(b64); // "SGVsbG8sIBZM"
}());
```
2012-09-19 14:22:55 -06:00
2018-03-27 22:44:53 -06:00
**Note**: Unicode may or may not be handled incorrectly.
This module is intended to provide exact compatibility with the browser.
2014-05-20 08:55:05 -06:00
2018-03-27 22:44:53 -06:00
Copyright and License
2014-05-20 08:55:05 -06:00
===
2018-03-27 22:44:53 -06:00
Code copyright 2012-2018 AJ ONeal
Dual-licensed MIT and Apache-2.0
2014-05-20 08:55:05 -06:00
2018-03-27 22:44:53 -06:00
Docs copyright 2012-2018 AJ ONeal
2014-05-20 08:55:05 -06:00
2018-03-27 22:44:53 -06:00
Docs released under [Creative Commons](https://git.coolaj86.com/coolaj86/btoa.js/blob/master/LICENSE.DOCS).