Prepare for Unicode 3.1 support.
[libiconv.git] / libcharset / tools / locale_x11encoding.c
blobf323cd25dfe3133c77fbc551f2602afa84b0a46a
1 /* Prints the locale's encoding via libX11. */
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <assert.h>
6 #include <locale.h>
7 #include <X11/Xlib.h>
8 #include <X11/Xutil.h>
10 int main (int argc, char* argv[])
12 Display* display;
13 XTextProperty textprop;
14 char* input;
16 if (argc != 1)
17 exit(1);
19 setlocale(LC_CTYPE,"");
21 display = XOpenDisplay(NULL);
22 if (display == NULL) {
23 fprintf(stderr,"cannot open display\n");
24 exit(1);
27 input = "";
28 if (XmbTextListToTextProperty(display, &input, 1, XTextStyle, &textprop) != Success) {
29 fprintf(stderr,"XmbTextListToTextProperty failed\n");
30 exit(1);
32 assert(textprop.format == 8);
33 assert(textprop.nitems == 0);
35 printf("%s\n", XGetAtomName(display, textprop.encoding));
37 XCloseDisplay(display);
39 exit(0);