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

Function toml_append_codepoint

src/cli/config_toml_edit.c:1153–1179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1151}
1152
1153static int toml_append_codepoint(toml_buffer_t *buffer, uint32_t codepoint) {
1154 char encoded[4];
1155 size_t len = 0;
1156 if (codepoint == 0 || codepoint > 0x10ffff || (codepoint >= 0xd800 && codepoint <= 0xdfff)) {
1157 return TOML_EDIT_ERR;
1158 }
1159 if (codepoint <= 0x7f) {
1160 encoded[0] = (char)codepoint;
1161 len = 1;
1162 } else if (codepoint <= 0x7ff) {
1163 encoded[0] = (char)(0xc0 | (codepoint >> 6));
1164 encoded[1] = (char)(0x80 | (codepoint & 0x3f));
1165 len = 2;
1166 } else if (codepoint <= 0xffff) {
1167 encoded[0] = (char)(0xe0 | (codepoint >> 12));
1168 encoded[1] = (char)(0x80 | ((codepoint >> 6) & 0x3f));
1169 encoded[2] = (char)(0x80 | (codepoint & 0x3f));
1170 len = 3;
1171 } else {
1172 encoded[0] = (char)(0xf0 | (codepoint >> 18));
1173 encoded[1] = (char)(0x80 | ((codepoint >> 12) & 0x3f));
1174 encoded[2] = (char)(0x80 | ((codepoint >> 6) & 0x3f));
1175 encoded[3] = (char)(0x80 | (codepoint & 0x3f));
1176 len = 4;
1177 }
1178 return toml_buffer_append(buffer, encoded, len);
1179}
1180
1181static int toml_parse_unicode_escape(const char *text, size_t len, size_t digits,
1182 uint32_t *out_codepoint) {

Callers 1

toml_parse_stringFunction · 0.85

Calls 1

toml_buffer_appendFunction · 0.85

Tested by

no test coverage detected