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

Function dg_utf8_bytes

internal/cbm/diagram.c:3307–3323  ·  view source on GitHub ↗

Code points up to U+00FF of UTF-8 text back to the bytes they stand for; * false on any other. */

Source from the content-addressed store, hash-verified

3305/* Code points up to U+00FF of UTF-8 text back to the bytes they stand for;
3306 * false on any other. */
3307static bool dg_utf8_bytes(const unsigned char *s, size_t n, unsigned char *out, size_t *len) {
3308 size_t w = 0;
3309 for (size_t i = 0; i < n; i++) {
3310 if (s[i] < DG_ASCII_END) {
3311 out[w++] = s[i];
3312 } else if ((s[i] & DG_UTF8_LEAD_MASK) == DG_UTF8_LEAD2 && i + SKIP_ONE < n &&
3313 s[i] <= DG_UTF8_LEAD_LATIN1) {
3314 out[w++] = (unsigned char)(((s[i] & DG_UTF8_LOW5) << CBM_SZ_6) |
3315 (s[i + SKIP_ONE] & DG_UTF8_LOW6));
3316 i++;
3317 } else {
3318 return false;
3319 }
3320 }
3321 *len = w;
3322 return true;
3323}
3324
3325/* An Excalidraw SVG export keeps its scene in a payload comment: base64 of a
3326 * JSON wrapper whose `encoded` byte string is the scene, zlib-compressed when

Callers 1

dg_excalidraw_svg_sceneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected