Group PJLIB_UTIL_STRING

group PJLIB_UTIL_STRING

Functions

pj_str_t pj_str_unescape(pj_pool_t *pool, const pj_str_t *src)

Unescape string. If source string does not contain any escaped characters, the function would simply return the original string. Otherwise a new string will be allocated.

Parameters:
  • pool – Pool to allocate the string.

  • src – Source string to unescape.

Returns:

String with no escaped characters.

pj_str_t *pj_strcpy_unescape(pj_str_t *dst, const pj_str_t *src)

Unescape string to destination.

Parameters:
  • dst – Target string.

  • src – Source string.

Returns:

Target string.

pj_str_t *pj_strncpy_escape(pj_str_t *dst, const pj_str_t *src, pj_ssize_t max, const pj_cis_t *unres)

Copy string to destination while escaping reserved characters, up to the specified maximum length.

Parameters:
  • dst – Target string.

  • src – Source string.

  • max – Maximum length to copy to target string.

  • unres – Unreserved characters, which are allowed to appear unescaped.

Returns:

The target string if all characters have been copied successfully, or NULL if there’s not enough buffer to escape the strings.

pj_ssize_t pj_strncpy2_escape(char *dst, const pj_str_t *src, pj_ssize_t max, const pj_cis_t *unres)

Copy string to destination while escaping reserved characters, up to the specified maximum length.

Parameters:
  • dst – Target string.

  • src – Source string.

  • max – Maximum length to copy to target string.

  • unres – Unreserved characters, which are allowed to appear unescaped.

Returns:

The length of the destination, or -1 if there’s not enough buffer.