Git Product home page Git Product logo

Comments (13)

xyz347 avatar xyz347 commented on June 8, 2024

现在就支持bom

from xpack.

XingYunSong avatar XingYunSong commented on June 8, 2024

在windows下解析UTF8带BOM的文件时就会报下面错误,就是没有支持BOM文件,去掉BOM的头就可以解析正确了
strError | "Parse json file "cfg/DataBrowserConfig.json" fail. err=Invalid value.. offset=锘縶\r\n\t"Description":"A Simulati" | std::basic_string<char,std::char_traits,std::allocator >

from xpack.

xyz347 avatar xyz347 commented on June 8, 2024

这个和bom没关系,应该是编码导致的,现在不支持gbk编码

from xpack.

XingYunSong avatar XingYunSong commented on June 8, 2024

图片
通过notpad++查看文件确定为UTF-8-BOM编码

from xpack.

xyz347 avatar xyz347 commented on June 8, 2024

贴一下json

from xpack.

XingYunSong avatar XingYunSong commented on June 8, 2024

{
"Description":"A Simulation Program",
"Version":"V1.0",
"DomainId":23
}

from xpack.

XingYunSong avatar XingYunSong commented on June 8, 2024

解析用的
xpack::json::decode_file("cfg/DataBrowserConfig.json", sConfigInfo);

from xpack.

xyz347 avatar xyz347 commented on June 8, 2024

我明天看看

from xpack.

XingYunSong avatar XingYunSong commented on June 8, 2024

像最开始那样在解析文件函数里面添加删除BOM头就可以成功解析,最开始里面有代码。好的,谢谢!

from xpack.

xyz347 avatar xyz347 commented on June 8, 2024

试了一下,Ubuntu(gcc)/Windows(msvc 2019)都是正常的,rapidjson处理了BOM了:https://github.com/xyz347/xpack/blob/master/rapidjson/encodedstream.h#L72

from xpack.

XingYunSong avatar XingYunSong commented on June 8, 2024

我用的VS2017
此处定义了一个strDeleteBom字符串,去掉BOM头,看到Json是正常的,作为对比
图片
通过两张图对比,当报错时,数据仍然是未去掉BOM头的内容,并且过程中没有调用到encodedstream.h#72这里
图片

from xpack.

xyz347 avatar xyz347 commented on June 8, 2024

用最新的xpack的代码

from xpack.

XingYunSong avatar XingYunSong commented on June 8, 2024

最新版本是可以的,

from xpack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.