MCPcopy Create free account
hub / github.com/antirez/ds4 / web_utf8_append

Function web_utf8_append

ds4_web.c:678–699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

676}
677
678static void web_utf8_append(web_buf *b, unsigned code) {
679 char out[4];
680 if (code <= 0x7f) {
681 out[0] = (char)code;
682 web_buf_append(b, out, 1);
683 } else if (code <= 0x7ff) {
684 out[0] = (char)(0xc0 | (code >> 6));
685 out[1] = (char)(0x80 | (code & 0x3f));
686 web_buf_append(b, out, 2);
687 } else if (code <= 0xffff) {
688 out[0] = (char)(0xe0 | (code >> 12));
689 out[1] = (char)(0x80 | ((code >> 6) & 0x3f));
690 out[2] = (char)(0x80 | (code & 0x3f));
691 web_buf_append(b, out, 3);
692 } else {
693 out[0] = (char)(0xf0 | (code >> 18));
694 out[1] = (char)(0x80 | ((code >> 12) & 0x3f));
695 out[2] = (char)(0x80 | ((code >> 6) & 0x3f));
696 out[3] = (char)(0x80 | (code & 0x3f));
697 web_buf_append(b, out, 4);
698 }
699}
700
701static char *web_json_parse_string_at(const char *q, const char **endp) {
702 if (*q != '"') return NULL;

Callers 1

web_json_parse_string_atFunction · 0.85

Calls 1

web_buf_appendFunction · 0.85

Tested by

no test coverage detected