---------------------------------------------------------------------- CEscape() CHexEscape() Utf8SafeCEscape() Utf8SafeCHexEscape() Copies 'src' to result, escaping dangerous characters using C-style escape sequences. This is very useful for preparing query flags. 'src' and 'dest' should not overlap. The 'Hex' version hexadecimal rather than octal sequences. The 'Utf8Safe' version doesn't touch U
| 582 | // Currently only \n, \r, \t, ", ', \ and !ascii_isprint() chars are escaped. |
| 583 | // ---------------------------------------------------------------------- |
| 584 | string CEscape(const StringPiece& src) { |
| 585 | const int dest_length = src.size() * 4 + 1; // Maximum possible expansion |
| 586 | unique_ptr<char[]> dest(new char[dest_length]); |
| 587 | const int len = CEscapeInternal(src.data(), src.size(), |
| 588 | dest.get(), dest_length, false, false); |
| 589 | DCHECK_GE(len, 0); |
| 590 | return string(dest.get(), len); |
| 591 | } |
| 592 | |
| 593 | string CHexEscape(const StringPiece& src) { |
| 594 | const int dest_length = src.size() * 4 + 1; // Maximum possible expansion |
no test coverage detected