20 template<
typename Output>
21 inline void XMLEscape(std::string_view s, Output output)
23 auto normal = [&](
auto f,
auto l) {
25 return std::string_view(&*f, l - f);
28 auto chunk = s.begin();
33 if (
auto uc =
static_cast<unsigned char>(c); uc < 32) {
34 output(normal(chunk, it));
35 char buf[6] = {
'&',
'#',
'x',
'0',
'0',
';'};
36 auto hex = [](
unsigned x) {
return (
x < 10) ? char(
x +
'0') : char(
x - 10 +
'a'); };
37 buf[3] = hex(uc / 16);
38 buf[4] = hex(uc % 16);
39 output(std::string_view(buf,
sizeof(buf)));
41 }
else if (c ==
'<') {
42 output(normal(chunk, it));
45 }
else if (c ==
'>') {
46 output(normal(chunk, it));
49 }
else if (c ==
'&') {
50 output(normal(chunk, it));
53 }
else if (c ==
'"') {
54 output(normal(chunk, it));
57 }
else if (c ==
'\'') {
58 output(normal(chunk, it));
66 output(normal(chunk, last));
73 XMLEscape(s, [&](std::string_view chunk) { result += chunk; });
void XMLEscape(std::string_view s, Output output)
constexpr KeyMatrixPosition x
Keyboard bindings.