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

Function utf8DecodePrev

linenoise.c:237–250  ·  view source on GitHub ↗

Decode the UTF-8 codepoint ending at position 'pos' (exclusive) and * return its value. Also sets *cplen to the byte length of the codepoint. */

Source from the content-addressed store, hash-verified

235 return cp;
236 } else if ((*p & 0xF0) == 0xE0) {
237 *len = 3;
238 cp = (*p & 0x0F) << 12;
239 cp |= (p[1] & 0x3F) << 6;
240 cp |= (p[2] & 0x3F);
241 return cp;
242 } else if ((*p & 0xF8) == 0xF0) {
243 *len = 4;
244 cp = (*p & 0x07) << 18;
245 cp |= (p[1] & 0x3F) << 12;
246 cp |= (p[2] & 0x3F) << 6;
247 cp |= (p[3] & 0x3F);
248 return cp;
249 }
250 *len = 1;
251 return *p; /* Fallback for invalid sequences. */
252}
253

Callers 1

utf8PrevCharLenFunction · 0.85

Calls 1

utf8DecodeCharFunction · 0.85

Tested by

no test coverage detected