mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix caret position for errors with utf source
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,4 +38,6 @@ inline bool validateUTF8(std::string const& _input)
|
||||
return validateUTF8(_input, invalidPos);
|
||||
}
|
||||
|
||||
size_t numCodepoints(std::string const& _utf8EncodedInput);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user