Replaces escape sequences with the real vales. Eg "Hello\nWorld" will have the '\n' replaced by the ASCII value for a newline. Handles \r, \t
| Return Type | Function name | Arguments |
|---|---|---|
| hzString | DeEscape | (hzString&,) |
Declared in file: hzTextproc.h
Defined in file : hzTextproc.cpp
Function Logic:
Function body:
hzString DeEscape (hzString& x)
{
// Category: Text Processing
//
// Replaces escape sequences with the real vales. Eg "Hello\nWorld" will have the '\n' replaced by the ASCII value for a newline. Handles \r, \t
//
// Arguments: 1) x Input string
//
// Returns: Instance of hzString by value being the unescaped translation of the supplied string
_hzfunc(__func__) ;
char* buf ; // Working buffer
char* j ; // Working buffer iterator
const char* i ; // Input string iterator
hzString result ; // Output string
if (!x.Length())
return result ;
j = buf = new char[x.Length() + 1];
for (i = *x ; *i ; i++)
{
if (*i == CHAR_BKSLASH)
{
i++ ;
if (*i == ''r''){ *j++ = CHAR_CR ; continue ; }
if (*i == ''n''){ *j++ = CHAR_NL ; continue ; }
if (*i == ''t''){ *j++ = CHAR_TAB ; continue ; }
if (*i == ''v''){ *j++ = CHAR_CTRLI ; continue ; }
if (*i == ''f''){ *j++ = CHAR_CTRLL ; continue ; }
if (*i == ''"''){*j++=CHAR_DQUOTE;continue ; }
if (*i == CHAR_BKSLASH)
{ *j++ = CHAR_BKSLASH ; continue ; }
i-- ;
}
if (*i == CHAR_HAT)
{
i++ ;
if (*i >&eq; ''A''&&*i <&eq; ''Z'')
{ *j++ = ((*i - ''A'')+1); continue ; }
i-- ;
}
*j++ = *i ;
}
*j = 0;
result = buf ;
delete buf ;
return result ;
}