| Programmer's Guide to the WvStreams Libraries | ||
|---|---|---|
| Prev | Chapter 7. WvEncoder - A top-level data encoder class | Next |
You almost never use this, but it's there if you need it. WvBackSlash performs C-style backslash escaping and unescaping of strings.
#include "wvbackslash.h"
#include "wvbufbase.h"
int main()
{
WvBackslashEncoder *enc;
enc = new WvBackslashEncoder("abcd");
//enc contains the letters you want to escape (add a backslash to)
//If you want a decoder, then enc has to be initialiazed like this:
//enc = new WvBackslashDecoder();
WvInPlaceBuf to_encode(20);
WvInPlaceBuf out(40);
to_encode.put("Test abcdefg",12);
//to_encode contains the string to be encoded
//(added a backslash(es) at the correct spot)
if (enc->encode(to_encode, out, true,true))
printf ("This is the result: %s\n", (char *) out.get(1));
//it will display on screen:
//This is the result: Test \a\b\c\defg
return 0;
}
It will display on screen:
This is the result: Test \a\b\c\defg