ddnet/src/base/unicode/tolower.cpp

29 lines
575 B
C++
Raw Normal View History

2022-02-14 23:22:52 +00:00
#include <cstdlib>
#include "tolower.h"
static int compul(const void *a, const void *b)
{
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;
}
2021-06-15 01:24:23 +00:00
extern "C" {
int str_utf8_tolower(int code)
{
struct UPPER_LOWER key;
struct UPPER_LOWER *res;
key.upper = code;
res = (UPPER_LOWER *)bsearch(&key, tolowermap, NUM_TOLOWER, sizeof(struct UPPER_LOWER), compul);
if(res == NULL)
return code;
return res->lower;
}
2021-06-15 01:24:23 +00:00
}
2022-05-06 18:31:24 +00:00
#define TOLOWER_DATA
#include "tolower_data.h"
2022-05-06 18:31:24 +00:00
#undef TOLOWER_DATA