| 9266 | // and may not be NUL-terminated. |
| 9267 | template <typename CharType> |
| 9268 | static void PrintCharsAsStringTo( |
| 9269 | const CharType* begin, size_t len, ostream* os) { |
| 9270 | const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\""; |
| 9271 | *os << kQuoteBegin; |
| 9272 | bool is_previous_hex = false; |
| 9273 | for (size_t index = 0; index < len; ++index) { |
| 9274 | const CharType cur = begin[index]; |
| 9275 | if (is_previous_hex && IsXDigit(cur)) { |
| 9276 | // Previous character is of '\x..' form and this character can be |
| 9277 | // interpreted as another hexadecimal digit in its number. Break string to |
| 9278 | // disambiguate. |
| 9279 | *os << "\" " << kQuoteBegin; |
| 9280 | } |
| 9281 | is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape; |
| 9282 | } |
| 9283 | *os << "\""; |
| 9284 | } |
| 9285 | |
| 9286 | // Prints a (const) char/wchar_t array of 'len' elements, starting at address |
| 9287 | // 'begin'. CharType must be either char or wchar_t. |
no test coverage detected