Trying out some different codepages for pdcurses/WIN32 and ncurses/Linux.

This commit is contained in:
Enno Rehling 2016-08-07 18:55:03 +02:00
parent 69c0194628
commit 400051332a
1 changed files with 28 additions and 3 deletions

View File

@ -78,11 +78,32 @@ state *current_state = NULL;
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) {
if (*rp & 0x80) {
while (*rp & 0x80) ++rp;
*wp++ = '?';
size_t sz = 0;
char ch;
CODEPAGE_TRANS(&ch, rp, &sz);
rp += sz;
*wp++ = ch;
}
else {
*wp++ = *rp++;
@ -91,6 +112,10 @@ static void simplify(const char *rp, char *wp) {
*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, ...) {
char buffer[128];
int result;