ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I actually don't know if I really need unicode, but judging on the things I recently read, I suppose this is the way to do what I want to. And it's to draw cyrillic text on a window that I'v created. For Latin I use XDrawString. Sadly, it can't draw cyrillic text or at least I don't know how to make my program do it.
Yes, this is something that I would be very, very interested in knowing. The area of apps I am looking to be programming in the future in (music sequencing, music typesetting) it would be very beneficial to use Unicode since it has musical glyphs and more that would be beneficial for output.
As I said I use Qt which does all the fiddly bits for me. However, briefly this is what you would need to do.
UTF-8 is a format which is used to store the characters and it will take between 1-4 bytes to represent a single character.
So when you read the data in you need to convert it from UTF-8 to UNICODE (strictly speaking it's UCS - universal character set), likewise when you save the data you need to convert from UCS to UTF-8.
Essentially the wchar_t is used to hold UCS characters. So you program should use wchar_t throughout and then the only difficulty arises when you come to IO. The basic steps are to set the locale, which gets messy (which is why I use libraries) when your text is using multiple locales.
Having said that glibc provides UNICODE support and once you have navigated the maze of wchar functions will enable you to write UNICODE applications.
Sorry for bring alive a relatively old thread, but I would like to know: how would a program display these Unicode characters (wchar_t-s) after converting them from UTF-8? Would XDrawString cut it, or would the individual characters in the individual fonts need to be copied into a pixmap, then posted to the screen (or a similar method)?
Yes, Xlib has supported Unicode for well over a decade now (since X11R5, I recall). And no, you don't need to try rendering your own bitmaps - XDraw* will do the job for you.
Having said that, however, you're probably much better off using a higher level toolkit (like "Qt" or "GTK+" ... or even Java Swing!) and let *it* manage the hoary details for you.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.