lq-text: LQU_cstring

API char * LQU_cstring (theString) CONST char *theString

Purpose

Converts any C escape sequences in the given string, and returns the result in a freshly malloc'd copy. The escape sequences currently recognised are \a (audible alert), \e (escape), \n (newline), \t (tab), \b (backspace), \r (return), \f (form feed), \\ (backslash), \' (single quote) and \" (double quote). The vertical tab (\v) is converted into a newline. The octal \ddd notation is understood; there can be up to three octal digits after the backslash. If you need to follow an octal escape with an ASCII digit, you should use all three digits, with leading zeros if necessary. The ANSI C \xDD hexadecimal notation is not supported.

Returns

A pointer to a freshly allocated buffer; it is the caller's responsibility to free this. If a null pointer was passed as an argument, however, a null pointer is returned.

Errors

Warns if an unrecognised escape sequence or trigraph was found

Bugs

Has support neither for hexadecimal escapes (\xDD) nor for trigraphs (perhaps this is a feature). There is no way to include ASCII NUL (\000) into a string, as this terminates it.