mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-01-10 17:30:13 +00:00
fix: diagnose, but not throw for unicode error
in 2.0.x and 2.1.0, README says "it shows warning" for invalid unicode codepoints. So far, this library just show an error message in stderr for this case. It is not good to change the behavior fatal in the next minor release, 2.1.1, that includes patches and improved error msgs. I will make it throw syntax_error after 2.2.0 for invalid unicode codepoints. For now, I will keep it to be "warning".
This commit is contained in:
parent
363927f489
commit
2accc9d22c
@ -250,10 +250,10 @@ std::string read_utf8_codepoint(const region<Container>& reg,
|
||||
{
|
||||
if(0xD800 <= codepoint && codepoint <= 0xDFFF)
|
||||
{
|
||||
throw syntax_error(format_underline("[error] "
|
||||
std::cerr << format_underline("[warning] "
|
||||
"toml::read_utf8_codepoint: codepoints in the range "
|
||||
"[0xD800, 0xDFFF] are not valid UTF-8.",
|
||||
loc, "not a valid UTF-8 codepoint"));
|
||||
loc, "not a valid UTF-8 codepoint") << std::endl;
|
||||
}
|
||||
assert(codepoint < 0xD800 || 0xDFFF < codepoint);
|
||||
// 1110yyyy 10yxxxxx 10xxxxxx
|
||||
@ -265,10 +265,10 @@ std::string read_utf8_codepoint(const region<Container>& reg,
|
||||
{
|
||||
if(0x10FFFF < codepoint) // out of Unicode region
|
||||
{
|
||||
throw syntax_error(format_underline("[error] "
|
||||
std::cerr << format_underline("[error] "
|
||||
"toml::read_utf8_codepoint: input codepoint is too large to "
|
||||
"decode as a unicode character.", loc,
|
||||
"should be in [0x00..0x10FFFF]"));
|
||||
"should be in [0x00..0x10FFFF]") << std::endl;
|
||||
}
|
||||
// 11110yyy 10yyxxxx 10xxxxxx 10xxxxxx
|
||||
character += static_cast<unsigned char>(0xF0| codepoint >> 18);
|
||||
|
Loading…
Reference in New Issue
Block a user