怪我咯2017-04-17 15:36:57
Are you talking about unicode character code or utf-8 character code.
If it is a unicode character code, it is similar to:
\u6c49\u5b57
Just save it like this.
But if it is
汉字
Such a character code, then you should convert it to Chinese characters and store it.
For specific coding issues, you can check out this link:
https://www.zhihu.com/questio...
黄舟2017-04-17 15:36:57
Because js has only one string type. This type is UCS-2/UTF-16. Only Blob or Buffer can truly save UTF-8 encoded data. Therefore, the GB2312 data you read through a web crawler should be directly converted into js internal strings, and then specify utf-8 encoding when saving using the fs API. In this way, the corresponding module is converted when saving.
If you want to convert it yourself, the result can only be placed in the Buffer and then written to the file.