MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / encode_utf8

Method encode_utf8

tests/autotester/json11.hpp:664–683  ·  view source on GitHub ↗

encode_utf8(pt, out) * * Encode pt as UTF-8 and add it to out. */

Source from the content-addressed store, hash-verified

662 * Encode pt as UTF-8 and add it to out.
663 */
664 void encode_utf8(long pt, string & out) {
665 if (pt < 0)
666 return;
667
668 if (pt < 0x80) {
669 out += static_cast<char>(pt);
670 } else if (pt < 0x800) {
671 out += static_cast<char>((pt >> 6) | 0xC0);
672 out += static_cast<char>((pt & 0x3F) | 0x80);
673 } else if (pt < 0x10000) {
674 out += static_cast<char>((pt >> 12) | 0xE0);
675 out += static_cast<char>(((pt >> 6) & 0x3F) | 0x80);
676 out += static_cast<char>((pt & 0x3F) | 0x80);
677 } else {
678 out += static_cast<char>((pt >> 18) | 0xF0);
679 out += static_cast<char>(((pt >> 12) & 0x3F) | 0x80);
680 out += static_cast<char>(((pt >> 6) & 0x3F) | 0x80);
681 out += static_cast<char>((pt & 0x3F) | 0x80);
682 }
683 }
684
685 /* parse_string()
686 *

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected