MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / countCodePointsWithSeqLength

Function countCodePointsWithSeqLength

src/Client/ClientBaseHelpers.cpp:146–156  ·  view source on GitHub ↗

Issue: https://github.com/ClickHouse/ClickHouse/issues/83987 countCodePointsWithSeqLength calculates utf-8 code point position consistently with colors vector allocation (with iteration and `UTF8::seqLength`). This function replaces the use of `UTF8::countCodePoints()`, since, `UTF8::countCodePoints` and `UTF8::seqLength` seem to handle invalid utf-8 sequences inconsistently (e.g., hex literals li

Source from the content-addressed store, hash-verified

144/// and crashes. TODO: @bharatnc fix `UTF8::countCodePoints` to handle invalid utf-8 sequences consistently
145/// with `UTF8::seqLength` so that this helper function's usage can be removed.
146static size_t countCodePointsWithSeqLength(const String & query, const char * end)
147{
148 size_t code_points = 0;
149 const char * pos = query.data();
150 while (pos < end)
151 {
152 pos += UTF8::seqLength(*pos);
153 ++code_points;
154 }
155 return code_points;
156}
157
158void highlight(const String & query, std::vector<replxx::Replxx::Color> & colors, const Context & context, int cursor_position, bool rainbow_parentheses)
159{

Callers 2

highlightFunction · 0.85
highlightedFunction · 0.85

Calls 2

seqLengthFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected