LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-16-2007, 09:29 PM   #1
kornerr
Member
 
Registered: Dec 2004
Location: Russia, Siberia, Kemerovo
Distribution: Slackware
Posts: 893

Rep: Reputation: 35
UTF-8 app. How?


How to make application UTF-8? Is it enough to use wstring?
Thanks.
 
Old 10-17-2007, 04:39 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Sadly, UTF-8 is not as simple as that. Look for a library that manages UNICODE characters. (If your using C++ you could try the QT library
 
Old 10-18-2007, 04:22 PM   #3
ivailo
LQ Newbie
 
Registered: Jun 2007
Location: Bulgaria
Distribution: Debian (etch)
Posts: 5

Rep: Reputation: 0
Hi,

Can I use unicode with xlib?

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.

Can anyone help me?

I will be quite grateful for any help.

Thanks in advance

Ivailo
 
Old 10-19-2007, 08:50 PM   #4
JMJ_coder
Member
 
Registered: Apr 2006
Distribution: Fedora
Posts: 478

Rep: Reputation: 30
Hello,

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.
 
Old 10-20-2007, 11:05 PM   #5
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 01-21-2008, 11:02 PM   #6
JoeyAdams
Member
 
Registered: Jun 2006
Distribution: Kubuntu Hardy
Posts: 94

Rep: Reputation: 15
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)?
 
Old 01-21-2008, 11:09 PM   #7
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

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.

Here are a couple of links:
http://www.debian.org/doc/manuals/in...output.en.html
http://eyegene.ophthy.med.umich.edu/unicode/
http://www.ibm.com/developerworks/ai...gtk/index.html

'Hope that helps .. PSM
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
im getting UTF-8 to STRING: Could not open converter from 'UTF-8' to 'ISO-8859-1' jabka Linux - Newbie 2 11-24-2006 05:44 AM
script or app mailcheck app from shell pandersson61 Linux - Software 1 03-24-2006 08:16 PM
How do I know how a file is encoded? UTF-8, UTF-16, etc.. ?? brynjarh Linux - General 1 12-03-2004 11:11 AM
[Enter] in text documents diffrent on Windows and Linux? UTF-8/UTF-16 problem or? brynjarh Linux - General 1 11-24-2004 05:20 AM
X11 / UTF-8 locale seems missing 'fr_FR.UTF-8' chrsitophermann Debian 11 07-17-2004 02:04 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration