2022-02-14 23:22:52 +00:00
|
|
|
#include <cstdlib>
|
2019-01-07 22:49:20 +00:00
|
|
|
|
|
|
|
#include "tolower_data.h"
|
|
|
|
|
|
|
|
static int compul(const void *a, const void *b)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
struct UPPER_LOWER *ul_a = (struct UPPER_LOWER *)a;
|
|
|
|
struct UPPER_LOWER *ul_b = (struct UPPER_LOWER *)b;
|
|
|
|
return ul_a->upper - ul_b->upper;
|
2019-01-07 22:49:20 +00:00
|
|
|
}
|
|
|
|
|
2021-06-15 01:24:23 +00:00
|
|
|
extern "C" {
|
2019-01-07 22:49:20 +00:00
|
|
|
int str_utf8_tolower(int code)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
struct UPPER_LOWER key;
|
|
|
|
struct UPPER_LOWER *res;
|
|
|
|
key.upper = code;
|
2021-06-15 01:24:23 +00:00
|
|
|
res = (UPPER_LOWER *)bsearch(&key, tolower, NUM_TOLOWER, sizeof(struct UPPER_LOWER), compul);
|
2019-01-07 22:49:20 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(res == NULL)
|
|
|
|
return code;
|
|
|
|
return res->lower;
|
2019-01-07 22:49:20 +00:00
|
|
|
}
|
2021-06-15 01:24:23 +00:00
|
|
|
}
|