node.js中的buffer.Buffer.isEncoding方法使用说明

时间:2014-12-14    点击:95   

方法说明:

检测是否为有效的编码参数,返回true 或 false。

语法:

复制代码 代码如下:

Buffer.isEncoding(encoding)

接收参数:

encoding {String}   被检测的编码格式

例子:

复制代码 代码如下:

var a = Buffer.isEncoding('base64');
 
console.log(a);

源码:

复制代码 代码如下:

Buffer.isEncoding = function(encoding) {
  switch ((encoding + '').toLowerCase()) {
    case 'hex':
    case 'utf8':
    case 'utf-8':
    case 'ascii':
    case 'binary':
    case 'base64':
    case 'ucs2':
    case 'ucs-2':
    case 'utf16le':
    case 'utf-16le':
    case 'raw':
      return true;
    default:
      return false;
  }
};

node.js中的buffer.copy方法使用说明
node.js中的buffer.fill方法使用说明
node.js中的buffer.length方法使用说明
node.js中的buffer.toJSON方法使用说明
node.js中的buffer.toString方法使用说明
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved