os/2 optionally builds against libiconv.

This commit is contained in:
Ozkan Sezer
2021-12-01 01:20:10 +03:00
parent b20484e803
commit 70c5e91d0f
4 changed files with 30 additions and 1 deletions

View File

@@ -38,10 +38,16 @@
#endif /* OS2DEBUG */
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
#define OS2_SysToUTF8(S) SDL_iconv_string("UTF-8", "", (char *)(S), SDL_strlen(S)+1)
#define OS2_UTF8ToSys(S) SDL_iconv_string("", "UTF-8", (char *)(S), SDL_strlen(S)+1)
#define libiconv_clean() do {} while(0)
#else
/* StrUTF8New() - geniconv/sys2utf8.c */
#include "geniconv/geniconv.h"
#define OS2_SysToUTF8(S) StrUTF8New(1, (S), SDL_strlen((S)) + 1)
#define OS2_UTF8ToSys(S) StrUTF8New(0, (char *)(S), SDL_strlen((S)) + 1)
#endif
/* SDL_OS2Quit() will be called from SDL_QuitSubSystem() */
void SDL_OS2Quit(void);

View File

@@ -320,10 +320,15 @@ static VOID _wmChar(WINDATA *pWinData, MPARAM mp1, MPARAM mp2)
}
if ((ulFlags & KC_CHAR) != 0) {
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
char *acUTF8 = SDL_iconv_string("UTF-8", "", (char *)&ulCharCode, 1);
SDL_SendKeyboardText((acUTF8 != NULL)? acUTF8 : (char *)&ulCharCode);
SDL_free(acUTF8);
#else
CHAR acUTF8[4];
LONG lRC = StrUTF8(1, acUTF8, sizeof(acUTF8), (PSZ)&ulCharCode, 1);
SDL_SendKeyboardText((lRC > 0)? acUTF8 : (PSZ)&ulCharCode);
#endif
}
}