diff options
Diffstat (limited to 'include/asterisk/json.h')
-rw-r--r-- | include/asterisk/json.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/asterisk/json.h b/include/asterisk/json.h index 28ebfbd51..cfd9a2997 100644 --- a/include/asterisk/json.h +++ b/include/asterisk/json.h @@ -217,6 +217,41 @@ const char *ast_json_typename(enum ast_json_type type); /*!@{*/ /*! + * \brief Check the string of the given length for UTF-8 format. + * \since 13.12.0 + * + * \param str String to check. + * \param len Length of string to check. + * + * \retval 0 if not UTF-8 encoded or str is NULL. + * \retval 1 if UTF-8 encoded. + */ +int ast_json_utf8_check_len(const char *str, size_t len); + +/*! + * \brief Check the nul terminated string for UTF-8 format. + * \since 13.12.0 + * + * \param str String to check. + * + * \retval 0 if not UTF-8 encoded or str is NULL. + * \retval 1 if UTF-8 encoded. + */ +int ast_json_utf8_check(const char *str); + +/*! + * \brief Check str for UTF-8 and replace with an empty string if fails the check. + * + * \note The convenience macro is normally used with ast_json_pack() + * or a function wrapper that calls ast_json_vpack(). + */ +#define AST_JSON_UTF8_VALIDATE(str) (ast_json_utf8_check(str) ? (str) : "") + +/*!@}*/ + +/*!@{*/ + +/*! * \brief Get the JSON true value. * \since 12.0.0 * |