Object 內置對象

對象TextDecoder

TextDecoder 解碼對象

創建方法

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

繼承關係

構造函數

TextDecoder

TextDecoder 對象構造函數,使用參數構造

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

調用參數:

  • codec: String, 指定解碼字符集
  • opts: Object, 指定解碼選項

成員屬性

encoding

String, 查詢當前的編碼字符集

1
readonly String TextDecoder.encoding;

成員函數

decode

將二進制數據轉換為文本

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

調用參數:

  • data:Buffer, 要轉換的二進制
  • opts: Object, 指定解碼選項

返回結果:

  • String, 返回解碼的文本

將二進制數據轉換為文本

1
String TextDecoder.decode();

返回結果:

  • String, 返回解碼的文本

toString

返回對象的字符串表示,一般返回"[Native Object]",對象可以根據自己的特性重新實現

1
String TextDecoder.toString();

返回結果:

  • String, 返回對象的字符串表示

toJSON

返回對象的JSON 格式表示,一般返回對象定義的可讀屬性集合

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

調用參數:

  • key: String, 未使用

返回結果:

  • Value, 返回包含可JSON 序列化的值