节点-从base64字符串转换为utf-8字节代码数组

时间:2018-06-19 18:01:06

标签: node.js utf-8 base64

我目前正在尝试将图像从基本64字符串转换为utf-8字节代码数组。为了清楚起见,下面是我尝试使用的代码替换为base 64字符串的代码。我得到了看起来是utf-8字节数组的内容,但是还没有找到一种验证方法。对帮助验证资源或代码是否不正确的任何帮助?

const b64 = '...base64 string';
// convert to utf8 string
const utf8 = (Buffer.from(b64, 'base64')).toString('utf8');
// create a buffer of utf8 string
const buff = Buffer.from(utf8, 'utf8');
// 
const arr = [...buff];

0 个答案:

没有答案
相关问题