| 172 | } |
| 173 | |
| 174 | static std::string internalUTF8MoveLeft(std::string_view utf8Text, int length /* default utf8Text.length() */) |
| 175 | { |
| 176 | if (!utf8Text.empty() && length > 0) |
| 177 | { |
| 178 | |
| 179 | // get the delete byte number |
| 180 | int deleteLen = 1; // default, erase 1 byte |
| 181 | |
| 182 | while (length >= deleteLen && 0x80 == (0xC0 & utf8Text.at(length - deleteLen))) |
| 183 | { |
| 184 | ++deleteLen; |
| 185 | } |
| 186 | |
| 187 | return std::string{utf8Text.data(), static_cast<size_t>(length - deleteLen)}; |
| 188 | } |
| 189 | else |
| 190 | { |
| 191 | return std::string{utf8Text}; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | static std::string internalUTF8MoveRight(std::string_view utf8Text, int length /* default utf8Text.length() */) |
| 196 | { |
no test coverage detected