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

Function toml_append_codepoint

src/cli/config_toml_edit.c:1115–1141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1113}
1114
1115static int toml_append_codepoint(toml_buffer_t *buffer, uint32_t codepoint) {
1116 char encoded[4];
1117 size_t len = 0;
1118 if (codepoint == 0 || codepoint > 0x10ffff || (codepoint >= 0xd800 && codepoint <= 0xdfff)) {
1119 return TOML_EDIT_ERR;
1120 }
1121 if (codepoint <= 0x7f) {
1122 encoded[0] = (char)codepoint;
1123 len = 1;
1124 } else if (codepoint <= 0x7ff) {
1125 encoded[0] = (char)(0xc0 | (codepoint >> 6));
1126 encoded[1] = (char)(0x80 | (codepoint & 0x3f));
1127 len = 2;
1128 } else if (codepoint <= 0xffff) {
1129 encoded[0] = (char)(0xe0 | (codepoint >> 12));
1130 encoded[1] = (char)(0x80 | ((codepoint >> 6) & 0x3f));
1131 encoded[2] = (char)(0x80 | (codepoint & 0x3f));
1132 len = 3;
1133 } else {
1134 encoded[0] = (char)(0xf0 | (codepoint >> 18));
1135 encoded[1] = (char)(0x80 | ((codepoint >> 12) & 0x3f));
1136 encoded[2] = (char)(0x80 | ((codepoint >> 6) & 0x3f));
1137 encoded[3] = (char)(0x80 | (codepoint & 0x3f));
1138 len = 4;
1139 }
1140 return toml_buffer_append(buffer, encoded, len);
1141}
1142
1143static int toml_parse_unicode_escape(const char *text, size_t len, size_t digits,
1144 uint32_t *out_codepoint) {

Callers 1

toml_parse_stringFunction · 0.85

Calls 1

toml_buffer_appendFunction · 0.85

Tested by

no test coverage detected