myscript.js 649 B

123456789101112131415161718192021222324
  1. var encoding = require("encoding");
  2. // Convert with encoding.convert()
  3. // var resultBuffer = encoding.convert(text, toCharset, fromCharset);
  4. // Where
  5. // text is either a Buffer or a String to be converted
  6. // toCharset is the characterset to convert the string
  7. // fromCharset (optional, defaults to UTF-8) is the source charset
  8. // Output of the conversion is always a Buffer object.
  9. // Example
  10. var result = encoding.convert("̸»°Ó뺢×Ó -- Ìý","gb2312" ,"UTF-8");
  11. var r = result.toString();
  12. console.log(r); //<Buffer d5 c4 d6 dc>
  13. var chaine1 = "Äã ¶ú ¶ä ÌÛ Â𠡢ʹ Ÿ¢ ¶ù ÑÊ Œž Ï ¶ù ¡£";