libsapling  0.8.0
Functions
text.h File Reference

Text utilities. More...

Go to the source code of this file.

Functions

void text__escape (char *dst, const char *src)
 Escapes some characters in a string. More...
 
void text__unescape (char *dst, const char *src)
 Unescapes some characters in a string. More...
 

Detailed Description

Text utilities.

Function Documentation

◆ text__escape()

void text__escape ( char *  dst,
const char *  src 
)

Escapes some characters in a string.

Parameters
dstPointer to the destination array where the escaped string will be stored.
srcString to be escaped.
Attention
Only escapes the following characters:
  • \ (Backslash)
  • " (Double quotation mark)
  • \t (Horizontal Tab)
  • \r (Carriage Return)
  • \n (Newline/Line Feed)
Warning
The destination array must be long enough to contain the escaped string (including the terminating null character). To be safe it should be twice as long as the original string plus one for the terminating null character (worst case: the original string only contains escapable characters). The terminating null character IS copied over to the destination array.

◆ text__unescape()

void text__unescape ( char *  dst,
const char *  src 
)

Unescapes some characters in a string.

Parameters
dstPointer to the destination array where the unescaped string will be stored.
srcString to be unescaped.
Attention
Only unescapes the following characters:
  • \ (Backslash)
  • " (Double quotation mark)
  • \t (Horizontal Tab)
  • \r (Carriage Return)
  • \n (Newline/Line Feed)
Warning
The destination array must be long enough to contain the unescaped string (including the terminating null character). To be safe it should be as long as the original string plus one for the terminating null character (worst case: the original string contains no characters to unescape). The terminating null character IS copied over to the destination array.