boost使用property_tree/json_parser处理包含中文字符的UTF8时异常的解决办法
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json

·
这主要是由json_parser_read.hpp里面的一个bug造成的,修改如下代码:
struct a_unicode
{context &c;
a_unicode(context &c): c(c) { }
void operator()(unsigned long u) const
{
//u = (std::min)(u, static_cast<unsigned long>((std::numeric_limits<Ch>::max)()));
typedef typename std::make_unsigned<Ch>::type UCh;
u = (std::min)(u, static_cast<unsigned long>((std::numeric_limits<UCh>::max)()));
c.string += Ch(u);
}
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json
};
如上修改在xcode和visual studio环境下编译正常,但在gcc环境下,可能需要修改typedef typename std::make_unsigned<Ch>::type UCh;为typedef typename make_unsigned<Ch>::type UCh;




适用于现代 C++ 的 JSON。
最近提交(Master分支:6 个月前 )
4424a0fc
Signed-off-by: Niels Lohmann <mail@nlohmann.me> 1 天前
11aa5f94
* Make std::filesystem::path conversion to/from UTF-8 encoded JSON string explicit.
Signed-off-by: Richard Musil <risa2000x@gmail.com>
* Experimental: Changing C++ standard detection logic to accommodate potential corner cases.
Signed-off-by: Richard Musil <risa2000x@gmail.com>
* Drop C++ standard tests for compilers which do not implement required features.
Signed-off-by: Richard Musil <risa2000x@gmail.com>
* Drop C++ standard tests for MSVC versions which do not implement required features.
Signed-off-by: Richard Musil <risa2000x@gmail.com>
---------
Signed-off-by: Richard Musil <risa2000x@gmail.com>
Co-authored-by: Richard Musil <risa2000x@gmail.com> 3 天前
更多推荐
所有评论(0)