Case-insensitive for endings within ASCII.
| 65 | |
| 66 | // Case-insensitive for endings within ASCII. |
| 67 | bool endsWith(const std::string& value, const std::string& ending) |
| 68 | { |
| 69 | if (ending.size() > value.size()) |
| 70 | return false; |
| 71 | |
| 72 | std::string lowercase(ending.size(), 0); |
| 73 | std::transform(value.rbegin(), |
| 74 | value.rbegin() + ending.size(), |
| 75 | lowercase.begin(), |
| 76 | [](unsigned char c) |
| 77 | { |
| 78 | return std::tolower(c); |
| 79 | }); |
| 80 | |
| 81 | return std::equal(ending.rbegin(), ending.rend(), value.rbegin()) || |
| 82 | std::equal(ending.rbegin(), ending.rend(), lowercase.begin()); |
| 83 | } |
| 84 | |
| 85 | std::string toUpper(const std::string& value) |
| 86 | { |
no test coverage detected