| 106 | |
| 107 | template<typename CHAR> |
| 108 | void PrepareForUTF8Output(const CHAR* src, |
| 109 | size_t src_len, |
| 110 | std::string* output) { |
| 111 | output->clear(); |
| 112 | if (src_len == 0) |
| 113 | return; |
| 114 | if (src[0] < 0x80) { |
| 115 | // Assume that the entire input will be ASCII. |
| 116 | output->reserve(src_len); |
| 117 | } else { |
| 118 | // Assume that the entire input is non-ASCII and will have 3 bytes per char. |
| 119 | output->reserve(src_len * 3); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | // Instantiate versions we know callers will need. |
| 124 | template void PrepareForUTF8Output(const wchar_t*, size_t, std::string*); |
no test coverage detected