MCPcopy Create free account
hub / github.com/apache/brpc / PrepareForUTF8Output

Function PrepareForUTF8Output

src/butil/strings/utf_string_conversion_utils.cc:108–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106
107template<typename CHAR>
108void 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.
124template void PrepareForUTF8Output(const wchar_t*, size_t, std::string*);

Callers 3

WideToUTF8Function · 0.85
UTF16ToUTF8Function · 0.85

Calls 2

clearMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected