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

Function Escape

lib/yamlcpp/src/exp.cpp:38–67  ·  view source on GitHub ↗

Escape . Translates the next 'codeLength' characters into a hex number and returns the result. . Throws if it's not actually hex.

Source from the content-addressed store, hash-verified

36// the result.
37// . Throws if it's not actually hex.
38std::string Escape(Stream& in, int codeLength) {
39 // grab string
40 std::string str;
41 for (int i = 0; i < codeLength; i++)
42 str += in.get();
43
44 // get the value
45 unsigned value = ParseHex(str, in.mark());
46
47 // legal unicode?
48 if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF) {
49 std::stringstream msg;
50 msg << ErrorMsg::INVALID_UNICODE << value;
51 throw ParserException(in.mark(), msg.str());
52 }
53
54 // now break it up into chars
55 if (value <= 0x7F)
56 return Str(value);
57
58 if (value <= 0x7FF)
59 return Str(0xC0 + (value >> 6)) + Str(0x80 + (value & 0x3F));
60
61 if (value <= 0xFFFF)
62 return Str(0xE0 + (value >> 12)) + Str(0x80 + ((value >> 6) & 0x3F)) +
63 Str(0x80 + (value & 0x3F));
64
65 return Str(0xF0 + (value >> 18)) + Str(0x80 + ((value >> 12) & 0x3F)) +
66 Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F));
67}
68
69// Escape
70// . Escapes the sequence starting 'in' (it must begin with a '\' or single

Callers 1

ScanScalarFunction · 0.70

Calls 7

ParseHexFunction · 0.85
ParserExceptionFunction · 0.85
stringClass · 0.85
StrFunction · 0.70
getMethod · 0.45
markMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected