Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22035

XDrawString incorrect encoding

$
0
0

I want to display cyrillic symbols with XDrawString(), but on screen they are shown in wrong encoding.

I have installed xfonts-cyrillic in my system (ubuntu 14.04), but still any font from xlsfonts list shows wrong result.

My code (main.cpp):

#include <X11/Xlib.h>#include <string.h>int main(int, char**){    Display *d = XOpenDisplay(0);    Window r = DefaultRootWindow(d);    Window w = XCreateSimpleWindow(d, r, 0, 0, 256, 256, 0, 0, 0xffffff);    GC gc = DefaultGC(d, 0);    XMapRaised(d, w);    XSelectInput(d, w, ExposureMask);    Font font = XLoadFont(d, "9x15-cyrillic");    XSetFont(d, gc, font);    const char *msg = "туттекст"; // cyrillic symbols    while (1)    {        XEvent e;        XNextEvent(d, &e);        XDrawString(d, w, gc, 16, 16, msg, (int) strlen(msg));    }}

Compile:

g++ -Wall -g -std=c++11 main.cpp -L/usr/lib/X11 -lX11 -o output

My result is:

enter image description here

Why in result window text is in wrong encoding? What I'm missing?


Viewing all articles
Browse latest Browse all 22035

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>