Copies the contents of s to out properly escaping any necessary characters. Returns the position next to last copied character.
| 168 | // Copies the contents of s to out properly escaping any necessary characters. |
| 169 | // Returns the position next to last copied character. |
| 170 | char* Escape(std::string_view s, char* out) { |
| 171 | for (const char c : s) { |
| 172 | *out++ = c; |
| 173 | if (c == '"') { |
| 174 | *out++ = '"'; |
| 175 | } |
| 176 | } |
| 177 | return out; |
| 178 | } |
| 179 | |
| 180 | // Return the index of the first structural char in the input. A structural char |
| 181 | // is a character that needs quoting and/or escaping. |
no outgoing calls
no test coverage detected