Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
pct.h File Reference

Percent-encoding and -decoding. More...

#include "roc_core/stddefs.h"
Include dependency graph for pct.h:

Go to the source code of this file.

Namespaces

 roc
 Root namespace.
 

Enumerations

enum  roc::address::PctMode { roc::address::PctNonUnreserved, roc::address::PctNonPath }
 Percent-encoding mode. More...
 

Functions

ssize_t roc::address::pct_encode (char *dst, size_t dst_sz, const char *src, size_t src_sz, PctMode mode)
 Percent-encode an UTF-8 string. More...
 
ssize_t roc::address::pct_decode (char *dst, size_t dst_sz, const char *src, size_t src_sz)
 Percent-decode an UTF-8 string. More...
 

Detailed Description

Percent-encoding and -decoding.

Definition in file pct.h.

Enumeration Type Documentation

Percent-encoding mode.

Enumerator
PctNonUnreserved 

Percent-encode all symbols that are not unreserved.

PctNonPath 

Percent-encode all symbols that are not allowed in path.

Definition at line 21 of file pct.h.

Function Documentation

ssize_t roc::address::pct_decode ( char *  dst,
size_t  dst_sz,
const char *  src,
size_t  src_sz 
)

Percent-decode an UTF-8 string.

Parameters

  • dst - destination buffer
  • dst_sz - destination buffer size
  • src - source string in UTF-8
  • src_sz - source string size
Returns
number of characters written to destination buffer, excluding the terminating zero byte, or -1 if the buffer is too small or the source string is invalid.
Remarks
The source string should NOT be null-terminated. The source string size should NOT include the terminating zero byte. The destination buffer size SHOULD include the terminating zero byte. If the function succeeded, the resulting string is ALWAYS null-terminated, but the returned size EXCLUDES the terminating zero byte.
ssize_t roc::address::pct_encode ( char *  dst,
size_t  dst_sz,
const char *  src,
size_t  src_sz,
PctMode  mode 
)

Percent-encode an UTF-8 string.

Parameters

  • dst - destination buffer
  • dst_sz - destination buffer size
  • src - source string in UTF-8
  • src_sz - source string size
  • mode - encoding mode
Returns
number of characters written to destination buffer, excluding the terminating zero byte, or -1 if the buffer is too small or the source string is invalid.
Remarks
The source string should NOT be null-terminated. The source string size should NOT include the terminating zero byte. The destination buffer size SHOULD include the terminating zero byte. If the function succeeded, the resulting string is ALWAYS null-terminated, but the returned size EXCLUDES the terminating zero byte.