Fix caret position for errors with utf source

This commit is contained in:
Mathias Baumann
2020-05-25 14:27:03 +02:00
parent 7a6ad61583
commit 7f3d437ffe
7 changed files with 31 additions and 4 deletions
+9
View File
@@ -138,4 +138,13 @@ bool validateUTF8(std::string const& _input, size_t& _invalidPosition)
return validateUTF8(reinterpret_cast<unsigned char const*>(_input.c_str()), _input.length(), _invalidPosition);
}
size_t numCodepoints(std::string const& _utf8EncodedInput)
{
size_t codepoint = 0;
for (char c: _utf8EncodedInput)
codepoint += (c & 0xc0) != 0x80;
return codepoint;
}
}
+2
View File
@@ -38,4 +38,6 @@ inline bool validateUTF8(std::string const& _input)
return validateUTF8(_input, invalidPos);
}
size_t numCodepoints(std::string const& _utf8EncodedInput);
}