summaryrefslogtreecommitdiff
path: root/include/asterisk/json.h
diff options
context:
space:
mode:
authorzuul <zuul@gerrit.asterisk.org>2016-10-14 12:54:52 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-10-14 12:54:52 -0500
commit05c6ab0d8fdc1dc6d213a40e9c2a4b5dc727cc20 (patch)
tree297a0f24b710ec5984012c8874d67e864beb3d0f /include/asterisk/json.h
parent4d1cb6a46d770e19f018a2421798621f98db6ac4 (diff)
parent9621c9bcbca70f61605606db8517a789f53f8600 (diff)
Merge "json: Add UTF-8 check call." into 13
Diffstat (limited to 'include/asterisk/json.h')
-rw-r--r--include/asterisk/json.h35
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
*