| 656 | } |
| 657 | |
| 658 | static size_t jl_encode_utf8(uint32_t codepoint, unsigned char output[4]) { |
| 659 | if (codepoint <= 0x7FU) { |
| 660 | output[0] = (unsigned char)codepoint; |
| 661 | return 1U; |
| 662 | } |
| 663 | if (codepoint <= 0x7FFU) { |
| 664 | output[0] = (unsigned char)(0xC0U | (codepoint >> 6U)); |
| 665 | output[1] = (unsigned char)(0x80U | (codepoint & 0x3FU)); |
| 666 | return 2U; |
| 667 | } |
| 668 | if (codepoint <= 0xFFFFU) { |
| 669 | output[0] = (unsigned char)(0xE0U | (codepoint >> 12U)); |
| 670 | output[1] = (unsigned char)(0x80U | ((codepoint >> 6U) & 0x3FU)); |
| 671 | output[2] = (unsigned char)(0x80U | (codepoint & 0x3FU)); |
| 672 | return 3U; |
| 673 | } |
| 674 | output[0] = (unsigned char)(0xF0U | (codepoint >> 18U)); |
| 675 | output[1] = (unsigned char)(0x80U | ((codepoint >> 12U) & 0x3FU)); |
| 676 | output[2] = (unsigned char)(0x80U | ((codepoint >> 6U) & 0x3FU)); |
| 677 | output[3] = (unsigned char)(0x80U | (codepoint & 0x3FU)); |
| 678 | return 4U; |
| 679 | } |
| 680 | |
| 681 | static uint32_t jl_decode_hex4(const char *text) { |
| 682 | uint32_t value = 0; |
no outgoing calls
no test coverage detected