File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / libiconv / libcharset / tools / locale_x11encoding.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 22:57:48 2012 UTC (12 years, 4 months ago) by misho
Branches: libiconv, MAIN
CVS tags: v1_16p0, v1_14p0, v1_14, v1_13_1, HEAD
libiconv

/* Prints the locale's encoding via libX11. */

#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <locale.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

int main (int argc, char* argv[])
{
  Display* display;
  XTextProperty textprop;
  char* input;

  if (argc != 1)
    exit(1);

  setlocale(LC_CTYPE,"");

  display = XOpenDisplay(NULL);
  if (display == NULL) {
    fprintf(stderr,"cannot open display\n");
    exit(1);
  }

  input = "";
  if (XmbTextListToTextProperty(display, &input, 1, XTextStyle, &textprop) != Success) {
    fprintf(stderr,"XmbTextListToTextProperty failed\n");
    exit(1);
  }
  assert(textprop.format == 8);
  assert(textprop.nitems == 0);

  printf("%s\n", XGetAtomName(display, textprop.encoding));

  XCloseDisplay(display);

  exit(0);
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>