| 122 | |
| 123 | template<typename OutputStream> |
| 124 | static void EncodeUnsafe(OutputStream& os, unsigned codepoint) { |
| 125 | if (codepoint <= 0x7F) |
| 126 | PutUnsafe(os, static_cast<Ch>(codepoint & 0xFF)); |
| 127 | else if (codepoint <= 0x7FF) { |
| 128 | PutUnsafe(os, static_cast<Ch>(0xC0 | ((codepoint >> 6) & 0xFF))); |
| 129 | PutUnsafe(os, static_cast<Ch>(0x80 | ((codepoint & 0x3F)))); |
| 130 | } |
| 131 | else if (codepoint <= 0xFFFF) { |
| 132 | PutUnsafe(os, static_cast<Ch>(0xE0 | ((codepoint >> 12) & 0xFF))); |
| 133 | PutUnsafe(os, static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F))); |
| 134 | PutUnsafe(os, static_cast<Ch>(0x80 | (codepoint & 0x3F))); |
| 135 | } |
| 136 | else { |
| 137 | RAPIDJSON_ASSERT(codepoint <= 0x10FFFF); |
| 138 | PutUnsafe(os, static_cast<Ch>(0xF0 | ((codepoint >> 18) & 0xFF))); |
| 139 | PutUnsafe(os, static_cast<Ch>(0x80 | ((codepoint >> 12) & 0x3F))); |
| 140 | PutUnsafe(os, static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F))); |
| 141 | PutUnsafe(os, static_cast<Ch>(0x80 | (codepoint & 0x3F))); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | template <typename InputStream> |
| 146 | static bool Decode(InputStream& is, unsigned* codepoint) { |
no test coverage detected