Replace GRBL realtime characters with the corresponding URI-style escape sequence.
| 69 | // Replace GRBL realtime characters with the corresponding URI-style |
| 70 | // escape sequence. |
| 71 | static std::string uriEncodeGrblCharacters(const char* clear) { |
| 72 | std::string escaped; |
| 73 | char c; |
| 74 | while ((c = *clear++) != '\0') { |
| 75 | switch (c) { |
| 76 | case '%': // The escape character itself |
| 77 | escaped += "%25"; |
| 78 | break; |
| 79 | case '!': // Cmd::FeedHold |
| 80 | escaped += "%21"; |
| 81 | break; |
| 82 | case '?': // Cmd::StatusReport |
| 83 | escaped += "%3F"; |
| 84 | break; |
| 85 | case '~': // Cmd::CycleStart |
| 86 | escaped += "%7E"; |
| 87 | break; |
| 88 | default: |
| 89 | escaped += c; |
| 90 | break; |
| 91 | } |
| 92 | } |
| 93 | return escaped; |
| 94 | } |
| 95 | |
| 96 | // Replace URI-style escape sequences like %HH with the character |
| 97 | // corresponding to the hex number HH. This works with any escaped |