Object built-in object

objectTextEncoder

TextEncoder encoding object

Create method

1
var textEncoder = new util.TextEncoder('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>TextEncoder|new TextEncoder()|encoding|encode()] [object] <:- [TextEncoder] TextEncoder new TextEncoder() encoding encode() object toString() toJSON()

Constructor

TextEncoder

TextEncoder object constructor, constructed with parameters

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

Call parameters:

  • codec: String, specifies the coded character set
  • opts: Object, specify encoding options

Member properties

encoding

String, query the current encoded character set

1
readonly String TextEncoder.encoding;

member function

encode

Convert text to binary data

1 2
Buffer TextEncoder.encode(String data = "", Object opts = {});

Call parameters:

  • data: String, the text to convert
  • opts: Object, specify encoding options

Return result:

  • Buffer, returns the encoded binary data

toString

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

1
String TextEncoder.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 TextEncoder.toJSON(String key = "");

Call parameters:

  • key: String, unused

Return result:

  • Value, returns a value containing JSON serializable