ibireme / yyjson

The fastest JSON library in C
https://ibireme.github.io/yyjson/doc/doxygen/html/
MIT License
3.04k stars 262 forks source link

Documentation does not specify if `len` set by write functions includes NULL terminator #115

Closed chad-earthscope closed 1 year ago

chad-earthscope commented 1 year ago

Describe the bug The write family of functions documents the result as:

The string is encoded as UTF-8 with a null-terminator.

and the len argument as:

The len is a pointer to receive output length, pass NULL if you don't need it.

but it is not clear if the null-terminator is included in the length. One might assume it's like strlen() and does not include the null-terminator. One might also assume it's the number of bytes written, which is +1, and get it wrong.

Additional context This suggestion is obviously a very minor clarification. A small addition to the docs, such as "not including terminator", could avoid writing test code to determine behavior and avoid the string equivalent of an off-by-one error.

ibireme commented 1 year ago

Thanks, the document has been updated.