MCPcopy Create free account
hub / github.com/apache/cloudberry / pg_utf8_string_len

Function pg_utf8_string_len

src/common/saslprep.c:1001–1020  ·  view source on GitHub ↗

* Calculate the length in characters of a null-terminated UTF-8 string. * * Returns -1 if the input is not valid UTF-8. */

Source from the content-addressed store, hash-verified

999 * Returns -1 if the input is not valid UTF-8.
1000 */
1001static int
1002pg_utf8_string_len(const char *source)
1003{
1004 const unsigned char *p = (const unsigned char *) source;
1005 int l;
1006 int num_chars = 0;
1007
1008 while (*p)
1009 {
1010 l = pg_utf_mblen(p);
1011
1012 if (!pg_utf8_islegal(p, l))
1013 return -1;
1014
1015 p += l;
1016 num_chars++;
1017 }
1018
1019 return num_chars;
1020}
1021
1022
1023/*

Callers 1

pg_saslprepFunction · 0.85

Calls 2

pg_utf_mblenFunction · 0.85
pg_utf8_islegalFunction · 0.85

Tested by

no test coverage detected