1#include <cstdlib>
2
3#include "tolower.h"
4
5static int compul(const void *a, const void *b)
6{
7 struct UPPER_LOWER *ul_a = (struct UPPER_LOWER *)a;
8 struct UPPER_LOWER *ul_b = (struct UPPER_LOWER *)b;
9 return ul_a->upper - ul_b->upper;
10}
11
12int str_utf8_tolower(int code)
13{
14 struct UPPER_LOWER key;
15 struct UPPER_LOWER *res;
16 key.upper = code;
17 res = (UPPER_LOWER *)bsearch(key: &key, base: tolowermap, nmemb: NUM_TOLOWER, size: sizeof(struct UPPER_LOWER), compar: compul);
18
19 if(res == NULL)
20 return code;
21 return res->lower;
22}
23
24#define TOLOWER_DATA
25#include "tolower_data.h"
26#undef TOLOWER_DATA
27