BSON_UNICHAR_T(3)
β¨ BSON_UNICHAR_T(3) β¨
okay so bestie, welcome to libbson's little corner of the manual devoted to one (1) very iconic thing: the Unicode Character Abstraction. yes that's the whole vibe. let's get into it π
πΈ SYNOPSIS πΈ
typedef uint32_t bson_unichar_t;
that's it. that's the girl. one typedef and she's already serving π
π¦ DESCRIPTION π¦
so like, bson_unichar_t is literally an abstraction on a single unicode character. it's the 32-bit representation of a character β yes, 32-bit, she's not doing the small-bit thing, she's doing the whole bit thing π
and here's the part where you gotta pay attention: since UTF-8 can contain multi-byte characters, this is the type you should be using when you're iterating through UTF-8 text. like, do not come in there poking at single bytes and expecting it to work, that's not the move. bson_unichar_t is the main character here, no cap π
lowkey important: multi-byte characters are exactly why this abstraction exists. use it when iterating UTF-8 text, fr fr.
π EXAMPLE π
here's a cute little function that prints out the numeric value of every character in a string, bestie:
static void
print_each_char (const char *str)
{
bson_unichar_t c;
for (; *str; str = bson_utf8_next_char (str)) {
c = bson_utf8_get_char (str);
printf ("The numberic value is %u.\n", (unsigned) c);
}
}
see how it walks the string with bson_utf8_next_char and pulls the character with bson_utf8_get_char? that's the whole pattern, and honestly? ate. π
(and yes, the format string in the original really does say numberic β we keep it exactly as-is, iconic typo and all, not me fixing it, never me fixing it π)
π AUTHOR π
MongoDB, Inc
β COPYRIGHT β
2009-present, MongoDB, Inc.
and that's the page! π«Ά cute little sign-off for you: this was libbson 2.5.6, dated Oct 09, 2026 β so go forth, iterate your UTF-8 like a legend, and remember: 32 bits of unicode excellence, periodt ππ§ββοΈ
π¦ where this page comes from
- epel 10: libbson-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms