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

Function csx_put_codepoint

internal/cbm/doclink_cs.c:3386–3404  ·  view source on GitHub ↗

A code point as UTF-8. A surrogate (a numeric reference may name one) is * no character: it is written as U+FFFD. */

Source from the content-addressed store, hash-verified

3384/* A code point as UTF-8. A surrogate (a numeric reference may name one) is
3385 * no character: it is written as U+FFFD. */
3386static void csx_put_codepoint(cs_sb_t *sb, uint32_t cp) {
3387 if (cp >= 0xD800 && cp <= 0xDFFF) {
3388 sb_puts(sb, CS_REPLACEMENT);
3389 } else if (cp < 0x80) {
3390 csx_put_char(sb, (unsigned char)cp);
3391 } else if (cp < 0x800) {
3392 sb_putc(sb, (char)(0xC0 | (cp >> 6)));
3393 sb_putc(sb, (char)(0x80 | (cp & 0x3F)));
3394 } else if (cp < 0x10000) {
3395 sb_putc(sb, (char)(0xE0 | (cp >> 12)));
3396 sb_putc(sb, (char)(0x80 | ((cp >> 6) & 0x3F)));
3397 sb_putc(sb, (char)(0x80 | (cp & 0x3F)));
3398 } else {
3399 sb_putc(sb, (char)(0xF0 | ((cp >> 18) & 0x07)));
3400 sb_putc(sb, (char)(0x80 | ((cp >> 12) & 0x3F)));
3401 sb_putc(sb, (char)(0x80 | ((cp >> 6) & 0x3F)));
3402 sb_putc(sb, (char)(0x80 | (cp & 0x3F)));
3403 }
3404}
3405
3406/* The entity at src[i] ('&' stands there): its code point and the index past
3407 * it; 0 when there is none. */

Callers 1

csx_put_textFunction · 0.85

Calls 3

sb_putsFunction · 0.85
csx_put_charFunction · 0.85
sb_putcFunction · 0.85

Tested by

no test coverage detected