| 1154 | public: |
| 1155 | PercentEncodeStream(OutputStream& os) : os_(os) {} |
| 1156 | void Put(char c) { // UTF-8 must be byte |
| 1157 | unsigned char u = static_cast<unsigned char>(c); |
| 1158 | static const char hexDigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; |
| 1159 | os_.Put('%'); |
| 1160 | os_.Put(static_cast<typename OutputStream::Ch>(hexDigits[u >> 4])); |
| 1161 | os_.Put(static_cast<typename OutputStream::Ch>(hexDigits[u & 15])); |
| 1162 | } |
| 1163 | private: |
| 1164 | OutputStream& os_; |
| 1165 | }; |