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

Function utf8_byte_pos

cpp/src/gandiva/precompiled/string_ops.cc:221–237  ·  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

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