objectTextEncoder
TextEncoder encoding object
Creation method
1var textEncoder = new util.TextEncoder('utf8');
inheritance relationship
Constructor
TextEncoder
TextEncoder object constructor, constructed with parameters
1
2new TextEncoder(String codec = "utf8",
Object opts = {});
Call parameters:
- codec: String, specifies the coded character set
- opts: Object, specifies encoding options
member attribute
encoding
String, query the current coded character set
1readonly String TextEncoder.encoding;
member function
encode
Convert text to binary data
1
2Buffer TextEncoder.encode(String data = "",
Object opts = {});
Call parameters:
- data: String, the text to convert
- opts: Object, specifies encoding options
return result:
- Buffer, returns encoded binary data
toString
Return the string representation of the object, generally return "[Native Object]", the object can be reimplemented according to its own characteristics
1String TextEncoder.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
1Value TextEncoder.toJSON(String key = "");
Call parameters:
- key: String, not used
return result:
- Value, which returns a JSON-serializable value