| 573 | } |
| 574 | |
| 575 | inline std::string percentEncodeURI (std::string_view text) |
| 576 | { |
| 577 | std::string result; |
| 578 | result.reserve (text.length()); |
| 579 | |
| 580 | for (auto c : text) |
| 581 | { |
| 582 | if (std::string_view ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.~").find (c) != std::string_view::npos) |
| 583 | { |
| 584 | result += c; |
| 585 | } |
| 586 | else |
| 587 | { |
| 588 | result += '%'; |
| 589 | result += "0123456789abcdef"[static_cast<uint8_t> (c) >> 4]; |
| 590 | result += "0123456789abcdef"[static_cast<uint8_t> (c) & 15u]; |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | return result; |
| 595 | } |
| 596 | |
| 597 | |
| 598 | } // namespace choc::text |