Object built-in object

ObjectTextEncoder

TextEncoder encoding object

Create method

1
var textEncoder = new util.TextEncoder('utf8');

inheritance relationship

Constructor

TextEncoder

TextEncoder object constructor, constructed using parameters

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

Call parameters:

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

member properties

encoding

String, query the current encoding 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 be converted
  • opts: Object, specify encoding options

Return results:

  • Buffer, returns encoded binary data

toString

Returns the string representation of the object. Generally, "[Native Object]" is returned. The object can be re-implemented according to its own characteristics.

1
String TextEncoder.toString();

Return results:

  • String, returns the string representation of the object

toJSON

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

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

Call parameters:

  • key: String, not used

Return results:

  • Value, returns a value containing JSON serializable