MCPcopy Create free account
hub / github.com/commonmark/cmark / cmark_utf8proc_encode_char

Function cmark_utf8proc_encode_char

src/utf8.c:189–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189void cmark_utf8proc_encode_char(int32_t uc, cmark_strbuf *buf) {
190 uint8_t dst[4];
191 bufsize_t len = 0;
192
193 assert(uc >= 0);
194
195 if (uc < 0x80) {
196 dst[0] = (uint8_t)(uc);
197 len = 1;
198 } else if (uc < 0x800) {
199 dst[0] = (uint8_t)(0xC0 + (uc >> 6));
200 dst[1] = 0x80 + (uc & 0x3F);
201 len = 2;
202 } else if (uc < 0x10000) {
203 dst[0] = (uint8_t)(0xE0 + (uc >> 12));
204 dst[1] = 0x80 + ((uc >> 6) & 0x3F);
205 dst[2] = 0x80 + (uc & 0x3F);
206 len = 3;
207 } else if (uc < 0x110000) {
208 dst[0] = (uint8_t)(0xF0 + (uc >> 18));
209 dst[1] = 0x80 + ((uc >> 12) & 0x3F);
210 dst[2] = 0x80 + ((uc >> 6) & 0x3F);
211 dst[3] = 0x80 + (uc & 0x3F);
212 len = 4;
213 } else {
214 encode_unknown(buf);
215 return;
216 }
217
218 cmark_strbuf_put(buf, dst, len);
219}
220
221#include "case_fold.inc"
222

Callers 2

houdini_unescape_entFunction · 0.85
cmark_render_code_pointFunction · 0.85

Calls 2

encode_unknownFunction · 0.85
cmark_strbuf_putFunction · 0.85

Tested by

no test coverage detected