MCPcopy Create free account
hub / github.com/aseprite/laf / utf8_icmp

Function utf8_icmp

base/string.cpp:227–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227int utf8_icmp(const std::string& a, const std::string& b, int n)
228{
229 utf8_decode a_decode(a);
230 utf8_decode b_decode(b);
231 int i = 0;
232
233 for (; (n == 0 || i < n) && !a_decode.is_end() && !b_decode.is_end(); ++i) {
234 int a_chr = a_decode.next();
235 if (!a_chr)
236 break;
237
238 int b_chr = b_decode.next();
239 if (!b_chr)
240 break;
241
242 a_chr = std::tolower(a_chr);
243 b_chr = std::tolower(b_chr);
244
245 if (a_chr < b_chr)
246 return -1;
247 if (a_chr > b_chr)
248 return 1;
249 }
250
251 if (n > 0 && i == n)
252 return 0;
253 if (a_decode.is_end() && b_decode.is_end())
254 return 0;
255 if (a_decode.is_end())
256 return -1;
257 return 1;
258}
259
260} // namespace base

Callers 2

has_file_extensionFunction · 0.85
TESTFunction · 0.85

Calls 2

is_endMethod · 0.80
nextMethod · 0.45

Tested by 1

TESTFunction · 0.68