MCPcopy Create free account
hub / github.com/apache/arrow / utf8_byte_pos

Function utf8_byte_pos

cpp/src/gandiva/precompiled/string_ops.cc:220–236  ·  view source on GitHub ↗

Get the byte position corresponding to a character position for a non-empty utf8 sequence

Source from the content-addressed store, hash-verified

218// Get the byte position corresponding to a character position for a non-empty utf8
219// sequence
220FORCE_INLINE
221gdv_int32 utf8_byte_pos(gdv_int64 context, const char* str, gdv_int32 str_len,
222 gdv_int32 char_pos) {
223 int char_len = 0;
224 int byte_index = 0;
225 for (gdv_int32 char_index = 0; char_index < char_pos && byte_index < str_len;
226 char_index++) {
227 char_len = utf8_char_length(str[byte_index]);
228 if (char_len == 0 ||
229 byte_index + char_len > str_len) { // invalid byte or incomplete glyph
230 set_error_for_invalid_utf(context, str[byte_index]);
231 return -1;
232 }
233 byte_index += char_len;
234 }
235 return byte_index;
236}
237
238#define UTF8_LENGTH(NAME, TYPE) \
239 FORCE_INLINE \

Callers 5

string_ops.ccFile · 0.85
locate_utf8_utf8_int32Function · 0.85
lpad_utf8_int32_utf8Function · 0.85
rpad_utf8_int32_utf8Function · 0.85
right_utf8_int32Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected