Object built-in object

objectTextDecoder

TextDecoder decoding object

Creation method

1
var textDecoder = new util.TextDecoder('utf8');

inheritance relationship

Constructor

TextDecoder

TextDecoder object constructor, constructed with parameters

1 2
new TextDecoder(String codec = "utf8", Object opts = {});

Call parameters:

  • codec: String, specifies the decoding character set
  • opts: Object, specifies decoding options

member attribute

encoding

String, query the current coded character set

1
readonly String TextDecoder.encoding;

member function

decode

Convert binary data to text

1 2
String TextDecoder.decode(Buffer data, Object opts = {});

Call parameters:

  • data:Buffer, the binary to convert
  • opts: Object, specifies decoding options

return result:

  • String, returns the decoded text

Convert binary data to text

1
String TextDecoder.decode();

return result:

  • String, returns the decoded text

toString

Return the string representation of the object, generally return "[Native Object]", the object can be reimplemented according to its own characteristics

1
String TextDecoder.toString();

return result:

  • String, returns a string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns a collection of readable properties defined by the object

1
Value TextDecoder.toJSON(String key = "");

Call parameters:

  • key: String, not used

return result:

  • Value, which returns a JSON-serializable value