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

Function pg_utf_mblen

src/common/wchar.c:567–589  ·  view source on GitHub ↗

* Return the byte length of a UTF8 character pointed to by s * * Note: in the current implementation we do not support UTF8 sequences * of more than 4 bytes; hence do NOT return a value larger than 4. * We return "1" for any leading byte that is either flat-out illegal or * indicates a length larger than we support. * * pg_utf2wchar_with_len(), utf8_to_unicode(), pg_utf8_islegal(), and perh

Source from the content-addressed store, hash-verified

565 * other places would need to be fixed to change this.
566 */
567int
568pg_utf_mblen(const unsigned char *s)
569{
570 int len;
571
572 if ((*s & 0x80) == 0)
573 len = 1;
574 else if ((*s & 0xe0) == 0xc0)
575 len = 2;
576 else if ((*s & 0xf0) == 0xe0)
577 len = 3;
578 else if ((*s & 0xf8) == 0xf0)
579 len = 4;
580#ifdef NOT_USED
581 else if ((*s & 0xfc) == 0xf8)
582 len = 5;
583 else if ((*s & 0xfe) == 0xfc)
584 len = 6;
585#endif
586 else
587 len = 1;
588 return len;
589}
590
591/*
592 * This is an implementation of wcwidth() and wcswidth() as defined in

Callers 10

unicode_normalize_funcFunction · 0.85
unicode_is_normalizedFunction · 0.85
UtfToLocalFunction · 0.85
pg_unicode_to_serverFunction · 0.85
utf8_to_iso8859_1Function · 0.85
json_lex_stringFunction · 0.85
pg_wchar2utf_with_lenFunction · 0.85
pg_utf8_string_lenFunction · 0.85
pg_saslprepFunction · 0.85
pg_unicode_to_serverFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected