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

Function toml_append_codepoint

src/cli/config_toml_edit.c:1249–1275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1247}
1248
1249static int toml_append_codepoint(toml_buffer_t *buffer, uint32_t codepoint) {
1250 char encoded[4];
1251 size_t len = 0;
1252 if (codepoint == 0 || codepoint > 0x10ffff || (codepoint >= 0xd800 && codepoint <= 0xdfff)) {
1253 return TOML_EDIT_ERR;
1254 }
1255 if (codepoint <= 0x7f) {
1256 encoded[0] = (char)codepoint;
1257 len = 1;
1258 } else if (codepoint <= 0x7ff) {
1259 encoded[0] = (char)(0xc0 | (codepoint >> 6));
1260 encoded[1] = (char)(0x80 | (codepoint & 0x3f));
1261 len = 2;
1262 } else if (codepoint <= 0xffff) {
1263 encoded[0] = (char)(0xe0 | (codepoint >> 12));
1264 encoded[1] = (char)(0x80 | ((codepoint >> 6) & 0x3f));
1265 encoded[2] = (char)(0x80 | (codepoint & 0x3f));
1266 len = 3;
1267 } else {
1268 encoded[0] = (char)(0xf0 | (codepoint >> 18));
1269 encoded[1] = (char)(0x80 | ((codepoint >> 12) & 0x3f));
1270 encoded[2] = (char)(0x80 | ((codepoint >> 6) & 0x3f));
1271 encoded[3] = (char)(0x80 | (codepoint & 0x3f));
1272 len = 4;
1273 }
1274 return toml_buffer_append(buffer, encoded, len);
1275}
1276
1277static int toml_parse_unicode_escape(const char *text, size_t len, size_t digits,
1278 uint32_t *out_codepoint) {

Callers 1

toml_parse_stringFunction · 0.85

Calls 1

toml_buffer_appendFunction · 0.85

Tested by

no test coverage detected