qse/samples/cmn/chr01.c

59 lines
914 B
C
Raw Normal View History

2012-01-03 14:41:15 +00:00
#include <qse/cmn/chr.h>
#include <qse/cmn/mbwc.h>
2016-04-29 03:55:42 +00:00
#include <qse/si/sio.h>
2012-01-03 14:41:15 +00:00
#include <locale.h>
#if defined(_WIN32)
# include <windows.h>
#endif
#define R(f) \
do { \
qse_printf (QSE_T("== %s ==\n"), QSE_T(#f)); \
if (f() == -1) return -1; \
} while (0)
static int test1 (void)
{
qse_char_t c;
for (c = QSE_T('a'); c <= QSE_T('z'); c++)
{
qse_printf (QSE_T("%c => %c\n"), c, QSE_TOUPPER(c));
}
return 0;
}
int main ()
{
#if defined(_WIN32)
2012-10-15 09:46:29 +00:00
char locale[100];
2012-01-03 14:41:15 +00:00
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
/*SetConsoleOUtputCP (CP_UTF8);*/
2012-10-15 09:36:39 +00:00
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
2012-01-03 14:41:15 +00:00
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
2012-01-03 14:41:15 +00:00
}
#else
setlocale (LC_ALL, "");
/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
2012-01-03 14:41:15 +00:00
#endif
2015-03-11 06:12:48 +00:00
2017-09-16 08:54:25 +00:00
qse_open_stdsios ();
2015-03-11 06:12:48 +00:00
2012-01-03 14:41:15 +00:00
R (test1);
2017-09-16 08:54:25 +00:00
qse_close_stdsios ();
2015-03-11 06:12:48 +00:00
2012-01-03 14:41:15 +00:00
return 0;
}