| 141 | } |
| 142 | |
| 143 | std::string EscapeBytesAsInvalidJSONString(const StringPiece& str, |
| 144 | bool put_in_quotes) { |
| 145 | std::string dest; |
| 146 | |
| 147 | if (put_in_quotes) |
| 148 | dest.push_back('"'); |
| 149 | |
| 150 | for (StringPiece::const_iterator it = str.begin(); it != str.end(); ++it) { |
| 151 | unsigned char c = *it; |
| 152 | if (EscapeSpecialCodePoint(c, &dest)) |
| 153 | continue; |
| 154 | |
| 155 | if (c < 32 || c > 126) |
| 156 | base::StringAppendF(&dest, kU16EscapeFormat, c); |
| 157 | else |
| 158 | dest.push_back(*it); |
| 159 | } |
| 160 | |
| 161 | if (put_in_quotes) |
| 162 | dest.push_back('"'); |
| 163 | |
| 164 | return dest; |
| 165 | } |
| 166 | |
| 167 | } // namespace base |
nothing calls this directly
no test coverage detected