Object built-in object

objectTextDecoder

TextDecoder decoding object

Create method

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

inheritance relationship

#lineWidth: 1.5 #font: Helvetica,sans-Serif #fontSize: 10 #leading: 1.6 #.this: fill=lightgray #.class: fill=white [<class>object|toString();toJSON()] [<this>TextDecoder|new TextDecoder()|encoding|decode()] [object] <:- [TextDecoder] TextDecoder new TextDecoder() encoding decode() object toString() toJSON()

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 properties

encoding

String, query the current encoded 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

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

1
String TextDecoder.toString();

Return result:

  • String, returns the string representation of the object

toJSON

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

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

Call parameters:

  • key: String, unused

Return result:

  • Value, returns a value containing JSON serializable