数码资讯
对buffer.buffer.bytelength方法在Node.js的使用说明
方法显示: 获取字符串的字节长度。 这个函数是不同的string.prototype.length,它返回一个字符串中的字符数。 Grammar: 复制代码代码如下所示: Buffer.byteLength(编码字符串,{ }) 接收参数: 字符串创建 编码字符串的编码,默认为utf8 实例uff1
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
方法显示:
获取字符串的字节长度。
这个函数是不同的string.prototype.length,它返回一个字符串中的字符数。
Grammar:
复制代码代码如下所示:
Buffer.byteLength(编码字符串,{ })
接收参数:
字符串创建
编码字符串的编码,默认为utf8
实例uff1a
复制代码代码如下所示:
str = u00bd + u00bc = u00be;
console.log(STR +:+ str.length + 字,+
Buffer.byteLength (STR,'utf8') + bytes);
1 2 + 1 4 = 3 4:9个字符,12字节
源代码 uff1a
复制代码代码如下所示:
buffer.bytelength =功能(STR,ENC){
VaR RET;
STR;
开关(ENC){
case'ascii:
case'binary:
case'raw:
str.length ret =;
打破;
case'ucs2:
case'ucs-2:
case'utf16le:
case'utf-16le:
ret = str.length * 2;
打破;
case'hex:
> > > 1 str.length ret =;
打破;
违约:
ret = internal.bytelength(STR,ENC);
}
返回页首;
};
获取字符串的字节长度。
这个函数是不同的string.prototype.length,它返回一个字符串中的字符数。
Grammar:
复制代码代码如下所示:
Buffer.byteLength(编码字符串,{ })
接收参数:
字符串创建
编码字符串的编码,默认为utf8
实例uff1a
复制代码代码如下所示:
str = u00bd + u00bc = u00be;
console.log(STR +:+ str.length + 字,+
Buffer.byteLength (STR,'utf8') + bytes);
1 2 + 1 4 = 3 4:9个字符,12字节
源代码 uff1a
复制代码代码如下所示:
buffer.bytelength =功能(STR,ENC){
VaR RET;
STR;
开关(ENC){
case'ascii:
case'binary:
case'raw:
str.length ret =;
打破;
case'ucs2:
case'ucs-2:
case'utf16le:
case'utf-16le:
ret = str.length * 2;
打破;
case'hex:
> > > 1 str.length ret =;
打破;
违约:
ret = internal.bytelength(STR,ENC);
}
返回页首;
};
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。