MCPcopy Create free account
hub / github.com/DFHack/dfhack / encode

Function encode

library/MiscUtils.cpp:550–569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

548/* Character encoding */
549
550static inline int encode(uint8_t *out, uint16_t c) {
551 if (c <= 0x7F)
552 {
553 out[0] = c;
554 return 1;
555 }
556 else if (c <= 0x7FF)
557 {
558 out[0] = (0xC0 | (c >> 6));
559 out[1] = (0x80 | (c & 0x3F));
560 return 2;
561 }
562 else /*if (c <= 0xFFFF)*/
563 {
564 out[0] = (0xE0 | (c >> 12));
565 out[1] = (0x80 | ((c >> 6) & 0x3F));
566 out[2] = (0x80 | (c & 0x3F));
567 return 3;
568 }
569}
570
571/* CP437 */
572

Callers 1

DF2UTFFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected