收藏
回答

读取txt文件里面的内容会乱码

https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.html

 {

     "button":[

     {    

         "name":"发货管理",

           "sub_button":[

           {    

               "type":"view",

               "name":"注册",

               "url":"http://sups.hangzhoutianqin.com/weixin/regist.aspx"

            }, {    

               "type":"view",

               "name":"待发货单",

               "url":"http://sups.hangzhoutianqin.com/weixin/sendmas.aspx"

            }, {    

               "type":"view",

               "name":"已发货",

               "url":"http://sups.hangzhoutianqin.com/weixin/sendlist.aspx"

            }, {    

               "type":"view",

               "name":"已验收",

               "url":"http://sups.hangzhoutianqin.com/weixin/reclist.aspx"

            }, {    

               "type":"view",

               "name":"已复核",

               "url":"http://sups.hangzhoutianqin.com/weixin/examlist.aspx"

            }]

      },

      {    

         "name":"我的信息",

           "sub_button":[

           {    

               "type":"view",

               "name":"采购合同",

               "url":"http://sups.hangzhoutianqin.com/weixin/contract.aspx"

            }, {    

               "type":"view",

               "name":"项目报表",

               "url":"http://sups.hangzhoutianqin.com/weixin/itemscontent.aspx"

            }, {    

               "type":"view",

               "name":"采购信息",

               "url":"http://sups.hangzhoutianqin.com/weixin/message.aspx"

            }, {    

               "type":"view",

               "name":"我的新材料",

               "url":"http://sups.hangzhoutianqin.com/weixin/mynewmaterial.aspx"

            }, {    

               "type":"view",

               "name":"我的资料",

               "url":"http://sups.hangzhoutianqin.com/weixin/mys.aspx"

            }]

      },

      {

           "name":"天勤动态",

           "sub_button":[

           {    

               "type":"view",

               "name":"新中标项目",

               "url":"http://sups.hangzhoutianqin.com/weixin/newitems.aspx"

            }, {    

               "type":"view",

               "name":"大宗采购单",

               "url":"http://sups.hangzhoutianqin.com/weixin/sendmas.aspx"

            }]

       }]

 }

经过读取,变成

 {\"button\":[\r\n     {\t\r\n         \"name\":\"鍙戣揣绠$悊\",\r\n           \"sub_button\":[\r\n           {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"娉ㄥ唽\",\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/regist.aspx\"\r\n            }, {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"寰呭彂璐у崟\",\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/sendmas.aspx\"\r\n            }, {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"宸插彂璐?,\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/sendlist.aspx\"\r\n            }, {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"宸查獙鏀?,\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/reclist.aspx\"\r\n            }, {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"宸插鏍?,\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/examlist.aspx\"\r\n            }]\r\n      },\r\n      {\t\r\n         \"name\":\"鎴戠殑淇℃伅\",\r\n           \"sub_button\":[\r\n           {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"閲囪喘鍚堝悓\",\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/contract.aspx\"\r\n            }, {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"椤圭洰鎶ヨ〃\",\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/itemscontent.aspx\"\r\n            }, {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"閲囪喘淇℃伅\",\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/message.aspx\"\r\n            }, {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"鎴戠殑鏂版潗鏂?,\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/mynewmaterial.aspx\"\r\n            }, {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"鎴戠殑璧勬枡\",\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/mys.aspx\"\r\n            }]\r\n      },\r\n      {\r\n           \"name\":\"澶╁嫟鍔ㄦ€?,\r\n           \"sub_button\":[\r\n           {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"鏂颁腑鏍囬」鐩?,\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/newitems.aspx\"\r\n            }, {\t\r\n               \"type\":\"view\",\r\n               \"name\":\"澶у畻閲囪喘鍗?,\r\n               \"url\":\"http://sups.hangzhoutianqin.com/weixin/sendmas.aspx\"\r\n            }]\r\n       }]\r\n }\r\n

回答关注问题邀请回答
收藏

2 个回答

  • 肖宇
    肖宇
    2020-04-27

    json数据保存成文件的话,存成json文件比较好

    --↓↓👍如果觉得有帮助的话请点个【有用】吧!

    2020-04-27
    有用
    回复
  • Mr.Zhao
    Mr.Zhao
    2020-04-27

    和txt啥关系

    2020-04-27
    有用
    回复 5
    • 🌾天 行
      🌾天 行
      2020-04-27
      正常不乱码的那部分,写在TXT文件里面
      2020-04-27
      回复
    • Mr.Zhao
      Mr.Zhao
      2020-04-27回复🌾天 行
      txt什么编码,GBK?
      2020-04-27
      回复
    • 🌾天 行
      🌾天 行
      2020-04-27
      gb2312
      2020-04-27
      回复
    • Mr.Zhao
      Mr.Zhao
      2020-04-27回复🌾天 行
      gb2312 不乱码才怪,程序和txt都用UTF-8
      2020-04-27
      1
      回复
    • 🌾天 行
      🌾天 行
      2020-04-27
      非常感谢,我居然把UTF-8给忘记了,解决了
      2020-04-27
      回复
登录 后发表内容
问题标签