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

Function output_text_requires_encoding

src/mcp/compact_out.c:143–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143static bool output_text_requires_encoding(const char *data, size_t len) {
144 static const char bytes_prefix[] = "@bytes:";
145 static const char utf8_prefix[] = "@utf8:";
146 if (!data) {
147 return len != 0;
148 }
149 if ((len >= sizeof(bytes_prefix) - 1 &&
150 memcmp(data, bytes_prefix, sizeof(bytes_prefix) - 1) == 0) ||
151 (len >= sizeof(utf8_prefix) - 1 &&
152 memcmp(data, utf8_prefix, sizeof(utf8_prefix) - 1) == 0)) {
153 return true;
154 }
155 size_t offset = 0;
156 while (offset < len) {
157 size_t sequence = utf8_sequence_length((const unsigned char *)data + offset, len - offset);
158 if (!sequence) {
159 return true;
160 }
161 offset += sequence;
162 }
163 return false;
164}
165
166bool cbm_output_encode_text(const char *data, size_t len, char **encoded, size_t *encoded_len) {
167 static const char bytes_prefix[] = "@bytes:";

Callers 3

cbm_output_encode_textFunction · 0.85
tree_prefix_choiceFunction · 0.85
tree_table_rows_implFunction · 0.85

Calls 1

utf8_sequence_lengthFunction · 0.85

Tested by

no test coverage detected