MCPcopy Create free account
hub / github.com/apache/trafficserver / EncodeToUtf8

Function EncodeToUtf8

lib/yamlcpp/test/integration/encoding_test.cpp:20–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20void EncodeToUtf8(std::ostream& stream, int ch) {
21 if (ch <= 0x7F) {
22 stream << Byte(ch);
23 } else if (ch <= 0x7FF) {
24 stream << Byte(0xC0 | (ch >> 6));
25 stream << Byte(0x80 | (ch & 0x3F));
26 } else if (ch <= 0xFFFF) {
27 stream << Byte(0xE0 | (ch >> 12));
28 stream << Byte(0x80 | ((ch >> 6) & 0x3F));
29 stream << Byte(0x80 | (ch & 0x3F));
30 } else if (ch <= 0x1FFFFF) {
31 stream << Byte(0xF0 | (ch >> 18));
32 stream << Byte(0x80 | ((ch >> 12) & 0x3F));
33 stream << Byte(0x80 | ((ch >> 6) & 0x3F));
34 stream << Byte(0x80 | (ch & 0x3F));
35 }
36}
37
38bool SplitUtf16HighChar(std::ostream& stream, EncodingFn encoding, int ch) {
39 int biasedValue = ch - 0x10000;

Callers 1

AddEntryMethod · 0.85

Calls 1

ByteFunction · 0.85

Tested by

no test coverage detected