V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
TomVista
V2EX  ›  Node.js

求助 http 编码 utf8,写入文件指定 utf8,生成 utf16le 文件

  •  
  •   TomVista · 2020-09-22 11:59:23 +08:00 · 4698 次点击
    这是一个创建于 1283 天前的主题,其中的信息可能已经有所发展或是发生改变。

    返回 header

    Headers {
       [Object: null prototype] {
         'content-encoding': [ 'gzip' ],
         'content-type': [ 'application/json; charset=utf-8' ],
         date: [ 'Tue, 22 Sep 2020 03:53:46 GMT' ],
         server: [ 'Caddy' ],
         'x-request-id': [ '' ],
         connection: [ 'close' ],
         'transfer-encoding': [ 'chunked' ] } }
    

    部分返回内容

    """
    鍦板潃鏀惰棌
    
    
    columns and relationships of "address"
    
    """
    type address {
      """鍦板潃琛屾斂鍒掑垎"""
      address_components(
        """JSON select path"""
        path: String
      ): jsonb
    
      """璇︾粏鍦板潃"""
      formatted_address: String
    
      """缁忕含搴?""
      geometry: geography
      id: uuid!
    

    文件写入

    fs.writeFileSync(output, '\uFEFF' + schema, {
          encoding: 'utf8',
        })
    

    最后文件是 utf16-le,转成 utf-8 会乱码?

    不清楚哪里出问题了

    第 1 条附言  ·  2020-09-22 12:49:15 +08:00
    有个沙雕,把日志文件和输出文件的默认名称设成一个了,默认指令不指定输出文件,会把 console.log 的历史内容写入默认输出文件 /日志文件,造成了现在这个样子
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1543 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:04 · PVG 01:04 · LAX 10:04 · JFK 13:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.