mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-06 23:16:21 +00:00
Convert case.cpp from C++ to C.
This commit is contained in:
@@ -25,8 +25,6 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
using namespace ucd;
|
||||
|
||||
// Unicode Character Data 8.0.0
|
||||
|
||||
struct case_conversion_entry
|
||||
@@ -37,7 +35,7 @@ struct case_conversion_entry
|
||||
codepoint_t titlecase;
|
||||
};
|
||||
|
||||
static const case_conversion_entry case_conversion_data[] =
|
||||
static const struct case_conversion_entry case_conversion_data[] =
|
||||
{
|
||||
{ 0x000041, 0x000000, 0x000061, 0x000000 },
|
||||
{ 0x000042, 0x000000, 0x000062, 0x000000 },
|
||||
@@ -2512,18 +2510,13 @@ static const case_conversion_entry case_conversion_data[] =
|
||||
};
|
||||
|
||||
codepoint_t ucd_toupper(codepoint_t c)
|
||||
{
|
||||
return ucd::toupper(c);
|
||||
}
|
||||
|
||||
ucd::codepoint_t ucd::toupper(codepoint_t c)
|
||||
{
|
||||
int begin = 0;
|
||||
int end = sizeof(case_conversion_data)/sizeof(case_conversion_data[0]);
|
||||
while (begin <= end)
|
||||
{
|
||||
int pos = (begin + end) / 2;
|
||||
const case_conversion_entry *item = (case_conversion_data + pos);
|
||||
const struct case_conversion_entry *item = (case_conversion_data + pos);
|
||||
if (c == item->codepoint)
|
||||
return item->uppercase == 0 ? c : item->uppercase;
|
||||
else if (c > item->codepoint)
|
||||
@@ -2535,18 +2528,13 @@ ucd::codepoint_t ucd::toupper(codepoint_t c)
|
||||
}
|
||||
|
||||
codepoint_t ucd_tolower(codepoint_t c)
|
||||
{
|
||||
return ucd::tolower(c);
|
||||
}
|
||||
|
||||
ucd::codepoint_t ucd::tolower(codepoint_t c)
|
||||
{
|
||||
int begin = 0;
|
||||
int end = sizeof(case_conversion_data)/sizeof(case_conversion_data[0]);
|
||||
while (begin <= end)
|
||||
{
|
||||
int pos = (begin + end) / 2;
|
||||
const case_conversion_entry *item = (case_conversion_data + pos);
|
||||
const struct case_conversion_entry *item = (case_conversion_data + pos);
|
||||
if (c == item->codepoint)
|
||||
return item->lowercase == 0 ? c : item->lowercase;
|
||||
else if (c > item->codepoint)
|
||||
@@ -2558,18 +2546,13 @@ ucd::codepoint_t ucd::tolower(codepoint_t c)
|
||||
}
|
||||
|
||||
codepoint_t ucd_totitle(codepoint_t c)
|
||||
{
|
||||
return ucd::totitle(c);
|
||||
}
|
||||
|
||||
ucd::codepoint_t ucd::totitle(codepoint_t c)
|
||||
{
|
||||
int begin = 0;
|
||||
int end = sizeof(case_conversion_data)/sizeof(case_conversion_data[0]);
|
||||
while (begin <= end)
|
||||
{
|
||||
int pos = (begin + end) / 2;
|
||||
const case_conversion_entry *item = (case_conversion_data + pos);
|
||||
const struct case_conversion_entry *item = (case_conversion_data + pos);
|
||||
if (c == item->codepoint)
|
||||
return item->titlecase == 0 ? c : item->titlecase;
|
||||
else if (c > item->codepoint)
|
||||
+12
-3
@@ -844,7 +844,10 @@ namespace ucd
|
||||
* @return The upper-case Unicode codepoint for this codepoint, or
|
||||
* this codepoint if there is no upper-case codepoint.
|
||||
*/
|
||||
codepoint_t toupper(codepoint_t c);
|
||||
inline codepoint_t toupper(codepoint_t c)
|
||||
{
|
||||
return ucd_toupper(c);
|
||||
}
|
||||
|
||||
/** @brief Convert the Unicode codepoint to lower-case.
|
||||
*
|
||||
@@ -856,7 +859,10 @@ namespace ucd
|
||||
* @return The lower-case Unicode codepoint for this codepoint, or
|
||||
* this codepoint if there is no upper-case codepoint.
|
||||
*/
|
||||
codepoint_t tolower(codepoint_t c);
|
||||
inline codepoint_t tolower(codepoint_t c)
|
||||
{
|
||||
return ucd_tolower(c);
|
||||
}
|
||||
|
||||
/** @brief Convert the Unicode codepoint to title-case.
|
||||
*
|
||||
@@ -868,7 +874,10 @@ namespace ucd
|
||||
* @return The title-case Unicode codepoint for this codepoint, or
|
||||
* this codepoint if there is no upper-case codepoint.
|
||||
*/
|
||||
codepoint_t totitle(codepoint_t c);
|
||||
inline codepoint_t totitle(codepoint_t c)
|
||||
{
|
||||
return ucd_totitle(c);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user