Module basic module

Module iconv

iconv encoding and decoding module

Reference method:

1 2
var encoding = require('encoding'); var iconv = encoding.iconv;

or

1
var iconv = require('iconv');

Static function

encode

Convert text to binary data with iconv

1 2
static Buffer iconv.encode(String charset, String data);

Call parameters:

  • charset : String, specify the character set
  • data : String, the text to be converted

Return result:

  • Buffer , returns the decoded binary data

decode

Use iconv to convert Buffer content to text

1 2
static String iconv.decode(String charset, Buffer data);

Call parameters:

  • charset : String, specify the character set
  • data : Buffer , the binary data to be converted

Return result:

  • String , returns the encoded string

isEncoding

Check whether the character set is supported

1
static Boolean iconv.isEncoding(String charset);

Call parameters:

  • charset : String, specify the character set

Return result:

  • Boolean , returns whether the character set is supported