React Native has a binaryToBase64 util that accepts ArrayBuffer for base64 conversions

12

React Native has a binaryToBase64 util that accepts ArrayBuffer for base64 conversions:

var utf8 = require(‘utf8’);
var binaryToBase64 = require(‘binaryToBase64’);

var text = ‘foo © bar 𝌆 baz’;
var bytes = utf8.encode(text);
var encoded = binaryToBase64(bytes);
console.log(encoded);
// Zm9vIMKpIGJhciDwnYyGIGJheg==
You might need to install the utf8 package, since it was removed from React Native on version 0.54:

npm install --save utf8
share improve this answer follow
edited Apr 4 '18 at 0:50

Rafa
7,44744 gold badges3131 silver badges57

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章