| 164 | } |
| 165 | |
| 166 | void UTF8::encodeCodepoint(char32_t codepoint, String* target) { |
| 167 | if (codepoint < 0b10000000) { |
| 168 | *target += (char) codepoint; |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | if (codepoint < 0b100000000000) { |
| 173 | *target += (char) (0b11000000 | ((codepoint >> 6) & 0b00011111)); |
| 174 | *target += (char) (0b10000000 | (codepoint & 0b00111111)); |
| 175 | return; |
| 176 | } |
| 177 | |
| 178 | else if (codepoint < 0b10000000000000000) { |
| 179 | *target += (char) (0b11100000 | ((codepoint >> 12) & 0b00001111)); |
| 180 | *target += (char) (0b10000000 | ((codepoint >> 6) & 0b00111111)); |
| 181 | *target += (char) (0b10000000 | (codepoint & 0b00111111)); |
| 182 | return; |
| 183 | } |
| 184 | |
| 185 | else if (codepoint < 0b1000000000000000000000) { |
| 186 | *target += (char) (0b11110000 | ((codepoint >> 18) & 0b00000111)); |
| 187 | *target += (char) (0b10000000 | ((codepoint >> 12) & 0b00111111)); |
| 188 | *target += (char) (0b10000000 | ((codepoint >> 6) & 0b00111111)); |
| 189 | *target += (char) (0b10000000 | (codepoint & 0b00111111)); |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | else if (codepoint < 0b100000000000000000000000000) { |
| 194 | *target += (char) (0b11111000 | ((codepoint >> 24) & 0b00000011)); |
| 195 | *target += (char) (0b10000000 | ((codepoint >> 18) & 0b00111111)); |
| 196 | *target += (char) (0b10000000 | ((codepoint >> 12) & 0b00111111)); |
| 197 | *target += (char) (0b10000000 | ((codepoint >> 6) & 0b00111111)); |
| 198 | *target += (char) (0b10000000 | (codepoint & 0b00111111)); |
| 199 | } |
| 200 | |
| 201 | else { |
| 202 | *target += (char) (0b11111100 | ((codepoint >> 30) & 0b00000001)); |
| 203 | *target += (char) (0b10000000 | ((codepoint >> 24) & 0b00111111)); |
| 204 | *target += (char) (0b10000000 | ((codepoint >> 18) & 0b00111111)); |
| 205 | *target += (char) (0b10000000 | ((codepoint >> 11) & 0b00111111)); |
| 206 | *target += (char) (0b10000000 | ((codepoint >> 6) & 0b00111111)); |
| 207 | *target += (char) (0b10000000 | (codepoint & 0b00111111)); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | } // namespace clip |
| 212 |
nothing calls this directly
no outgoing calls
no test coverage detected