GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
BSON_UTF8_ESCAPE_FOR_JSON(3) libbson BSON_UTF8_ESCAPE_FOR_JSON(3)

char *
bson_utf8_escape_for_json (const char *utf8, ssize_t utf8_len);


  • utf8: A UTF-8 encoded string.
  • utf8_len: The length of utf8 in bytes or -1 if it is NULL terminated.

Allocates a new string matching utf8 except that special characters in JSON are escaped. The resulting string is also UTF-8 encoded.

Both " and \ characters will be backslash-escaped. If a NUL byte is found before utf8_len bytes, it is converted to "\u0000". Other non-ASCII characters in the input are preserved.

The two-byte sequence "C0 80" is also interpreted as an internal NUL, for historical reasons. This sequence is considered invalid according to RFC3629.

A newly allocated string that should be freed with bson_free() when utf8 is a valid UTF-8 string, or NULL if the (possibly invalid UTF-8) string could not be escaped.

MongoDB, Inc

2009-present, MongoDB, Inc.

July 3, 2025 1.30.4

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.