Skip to content

Instantly share code, notes, and snippets.

@chryss
Created August 7, 2010 11:50
Show Gist options
  • Save chryss/512731 to your computer and use it in GitHub Desktop.
Save chryss/512731 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <locale.h>
#define MYLOCALE "de_DE.UTF-8"
int main (void) {
struct lconv *locale_ptr;
wchar_t a = L'a';
wchar_t a1 = L'ä';
wchar_t b = L'z';
wchar_t wrd[] = {a, a1, b, '\0'};
if (setlocale(LC_ALL, MYLOCALE) == NULL) {
fprintf(stderr, "Can't set the locale %s. "
"Check LANG, LC_CTYPE, LC_ALL.\n", MYLOCALE);
return 1;
}
locale_ptr = localeconv();
printf("Currency symbol: %s\n", locale_ptr->currency_symbol);
printf("%lc\n", a);
printf("%lc\n", a1);
printf("%lc\n", b);
printf("%ls\n", wrd);
printf("%zu\n", sizeof wrd);
printf("%zu\n", sizeof a1);
printf("%zu\n", sizeof b);
printf("%zu\n", wcslen(wrd));
printf("%d\n", wcscoll(&a, &a1));
printf("%d\n", wcscoll(&a1, &b));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment