| 279 | } |
| 280 | |
| 281 | static std::string EncodeChar(char ch) |
| 282 | { |
| 283 | std::ostringstream ss; |
| 284 | |
| 285 | ss.imbue(std::locale::classic()); |
| 286 | ss.fill('0'); |
| 287 | ss.setf(std::ios_base::hex, std::ios_base::basefield); |
| 288 | ss.width(2); |
| 289 | |
| 290 | ss << (unsigned int)(unsigned char)ch; |
| 291 | |
| 292 | ASSERT(ss.str().length() == 2); |
| 293 | |
| 294 | // Make sure the hex is uppercase |
| 295 | std::string s = ss.str(); |
| 296 | std::transform(s.begin(), s.end(), s.begin(), toupper); |
| 297 | |
| 298 | return s; |
| 299 | } |
| 300 | |
| 301 | |
| 302 | /* static */ |