MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / jl_encode_utf8

Function jl_encode_utf8

src/cli/config_json_like.c:658–679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

656}
657
658static 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
681static uint32_t jl_decode_hex4(const char *text) {
682 uint32_t value = 0;

Callers 2

jl_key_equalsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected