BSON_UTF8_VALIDATE(3)
π BSON_UTF8_VALIDATE(3) π
okay so bestie, you're in libbson land and you need to know if a string is actually valid UTF-8 before you go handing it to anything important. this little function is your vibe check for bytes. she's not flashy, she just does her job and she does it flawlessly. π§β¨
β¨ SYNOPSIS β¨
bool
bson_utf8_validate (const char *utf8, size_t utf8_len, bool allow_null);
π«Ά PARAMETERS π«Ά
utf8β the string you want to verify. like, the actual thing you're suspicious of. hand her over. πutf8_lenβ how longutf8is, in bytes (not characters, bestie, bytes, this is important, iykyk). πallow_nullβ aboolthat says whether embedded\0bytes are allowed.true= yeah babes, nulls welcome.false= absolutely not. π«
πΈ DESCRIPTION πΈ
so what she does is: she validates that the content inside utf8 is valid UTF-8 β and not just by vibe, by the RFC 3629 standard, which is the real one, no cap. ππ
and if allow_null is true, then embedded NULL bytes are allowed too (\0). literally she'll just let them vibe there. if it's false... those nulls are not invited to the party. π
fr fr, this is the standard-compliance check, not a "close enough" check. she read the whole RFC. she took notes. she's that girl. π
β RETURNS β
true if utf8 contains valid UTF-8. that's it. that's the whole answer. slay. π
π AUTHOR π
MongoDB, Inc β iconic behavior, honestly. π«‘
π COPYRIGHT π
2009-present, MongoDB, Inc. β a whole era, and she's still serving. π
okay that's the whole page bestie!! huge thank you to the fine people at libbson version 2.5.6, dated Oct 09, 2026 β go validate some bytes, be safe, and remember: it's bytes, not characters. mwah πβ¨π
π¦ 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