我一直在尝试在互联网上阅读大量资源,试图找到一种从X显示器获得UTF-8键盘(组合)输入的方法.但我无法使其发挥作用.
我已经尝试过这个链接的示例代码(exaple 11-4),但没有成功.
我还写了一个简单的例子(下面),试图让它工作.我的简单测试用例是打印一个"é",通过输入急性然后输入e来实现.
怎么了?
谢谢,
这是我的例子:
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xresource.h>
#include <X11/Xlocale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char ** argv)
{
int screen_num, width, height;
unsigned long background, border;
Window win;
XEvent ev;
Display *dpy;
XIM im;
XIC ic;
char *failed_arg;
XIMStyles *styles;
XIMStyle xim_requested_style;
/* First connect to the display server, as specified in the DISPLAY
environment variable. */
if (setlocale(LC_ALL, "") == NULL) {
return 9;
}
if (!XSupportsLocale()) …Run Code Online (Sandbox Code Playgroud)