Return the number of bytes required to UTF8-encode the given codepoint
| 310 | |
| 311 | /// Return the number of bytes required to UTF8-encode the given codepoint |
| 312 | static inline int32_t UTF8EncodedLength(uint32_t codepoint) { |
| 313 | if (codepoint < 0x80) { |
| 314 | return 1; |
| 315 | } else if (codepoint < 0x800) { |
| 316 | return 2; |
| 317 | } else if (codepoint < 0x10000) { |
| 318 | return 3; |
| 319 | } else { |
| 320 | return 4; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | static inline uint8_t* UTF8Encode(uint8_t* str, uint32_t codepoint) { |
| 325 | if (codepoint < 0x80) { |