MCPcopy Create free account
hub / github.com/NativeScript/android / encode_json

Function encode_json

test-app/runtime/src/main/cpp/ada/ada.cpp:11132–11154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11130
11131template <typename out_iter>
11132void encode_json(std::string_view view, out_iter out) {
11133 // trivial implementation. could be faster.
11134 const char* hexvalues =
11135 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";
11136 for (uint8_t c : view) {
11137 if (c == '\\') {
11138 *out++ = '\\';
11139 *out++ = '\\';
11140 } else if (c == '"') {
11141 *out++ = '\\';
11142 *out++ = '"';
11143 } else if (c <= 0x1f) {
11144 *out++ = '\\';
11145 *out++ = 'u';
11146 *out++ = '0';
11147 *out++ = '0';
11148 *out++ = hexvalues[2 * c];
11149 *out++ = hexvalues[2 * c + 1];
11150 } else {
11151 *out++ = c;
11152 }
11153 }
11154}
11155
11156ada_unused std::string get_state(ada::state s) {
11157 switch (s) {

Callers 1

to_stringMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected