BSON_STRING_TRUNCATE(3)

okay bestie, welcome to the BSON_STRING_TRUNCATE(3) page from the libbson manual β€” yes, that libbson, the BSON girlies' favorite C library. this one's short but she has LORE, so let's get into it πŸ’…βœ¨


🚨 WARNING β€” she's deprecated, bestie 🚨

Deprecated since version 1.29.0.

like… not me showing up late to tell you this function is old news 😭 still gotta document her tho, periodt.


πŸ“œ SYNOPSIS

void
bson_string_truncate (bson_string_t *string, uint32_t len);

that's the whole signature, no cap. returns void, so don't go looking for a return value πŸ’€


πŸŽ€ PARAMETERS

  • string β€” A bson_string_t. the string you're about to snip snip βœ‚οΈ
  • len β€” The new length of the string, excluding the trailing \0. so like, the actual character-ish bytes, not counting the terminator 🫢

πŸ’… DESCRIPTION

Truncates the string so that it is len bytes in length. and this len must be smaller or equal to the current length of the string β€” no glow-ups allowed, only glow-downs πŸ’‡β€β™€οΈ

A \0 byte will be placed where the end of the string occurs. so the string still knows where it ends, iconic behavior honestly πŸŽ€

⚠️ WARNING: This function is oblivious to UTF-8 structure. If truncation occurs in the middle of a UTF-8 byte sequence, the resulting bson_string_t will contain invalid UTF-8. like she will literally chop a character in half and not even feel bad about it 😭 valid UTF-8? she doesn't know her.
⚠️ WARNING: The length of the resulting string (including the NULL terminator) MUST NOT exceed UINT32_MAX. this is a hard limit, bestie β€” not a vibe suggestion. do not play with UINT32_MAX, she will not survive it πŸ’€

πŸ‘‘ AUTHOR

MongoDB, Inc


2009-present, MongoDB, Inc.


and that's the whole page, babe πŸ’– this was libbson version 1.30.13, dated Oct 09, 2026, and honestly? she ate. deprecated and all. bye bestie πŸ¦‹βœ¨

πŸ“¦ where this page comes from