forked from github/server
Trying out some different codepages for pdcurses/WIN32 and ncurses/Linux.
This commit is contained in:
parent
69c0194628
commit
400051332a
31
src/gmtool.c
31
src/gmtool.c
|
@ -78,11 +78,32 @@ state *current_state = NULL;
|
||||||
|
|
||||||
static WINDOW *hstatus;
|
static WINDOW *hstatus;
|
||||||
|
|
||||||
static void simplify(const char *rp, char *wp) {
|
static int unicode_utf8_to_ascii(char *result, const utf8_t * utf8_string,
|
||||||
|
size_t *length)
|
||||||
|
{
|
||||||
|
int retval = unicode_utf8_to_cp437(result, utf8_string, length);
|
||||||
|
if (*length > 1) {
|
||||||
|
*result = '?';
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define CODEPAGE_TRANS unicode_utf8_to_cp1252
|
||||||
|
#elif defined(NCURSES_VERSION)
|
||||||
|
#define CODEPAGE_TRANS unicode_utf8_to_cp437
|
||||||
|
#else
|
||||||
|
#define CODEPAGE_TRANS unicode_utf8_to_ascii
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void unicode_remove_diacritics(const char *rp, char *wp) {
|
||||||
while (*rp) {
|
while (*rp) {
|
||||||
if (*rp & 0x80) {
|
if (*rp & 0x80) {
|
||||||
while (*rp & 0x80) ++rp;
|
size_t sz = 0;
|
||||||
*wp++ = '?';
|
char ch;
|
||||||
|
CODEPAGE_TRANS(&ch, rp, &sz);
|
||||||
|
rp += sz;
|
||||||
|
*wp++ = ch;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*wp++ = *rp++;
|
*wp++ = *rp++;
|
||||||
|
@ -91,6 +112,10 @@ static void simplify(const char *rp, char *wp) {
|
||||||
*wp = 0;
|
*wp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void simplify(const char *rp, char *wp) {
|
||||||
|
unicode_remove_diacritics(rp, wp);
|
||||||
|
}
|
||||||
|
|
||||||
int umvwprintw(WINDOW *win, int y, int x, const char *format, ...) {
|
int umvwprintw(WINDOW *win, int y, int x, const char *format, ...) {
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
int result;
|
int result;
|
||||||
|
|
Loading…
Reference in New Issue