LinuxQuestions.org
Help answer threads with 0 replies.
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 05-01-2006, 09:51 PM   #1
George2
Member
 
Registered: Oct 2003
Posts: 354

Rep: Reputation: 30
Looking for C/C++ unicode related programming tutorial


Hello everyone,


I am looking for C/C++ unicode related programming tutorials. Here is my requirement,

- To write programs for both Windows and Linux platform with unicode support;
- To port program with unicode support from Windows to Linux platform.


thanks in advance,
George
 
Old 05-01-2006, 10:02 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
The reason I suggested Qt in your earlier thread was that it hides much of the complexity of Unicode. From personal experience I would avoid doing it in C/C++ and use a library.

For all thing UNICODE you can go to the official UNICODE site.
 
Old 05-02-2006, 03:44 AM   #3
MichaelZ
Member
 
Registered: Mar 2006
Location: Austria
Distribution: Ubuntu Breezy 5.10
Posts: 32

Rep: Reputation: 15
Hello,

Give also a look at:

www.wxWidgets.org

Best wishes,
Michael
 
Old 05-02-2006, 07:08 AM   #4
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thanks graemef!


Quote:
Originally Posted by graemef
The reason I suggested Qt in your earlier thread was that it hides much of the complexity of Unicode. From personal experience I would avoid doing it in C/C++ and use a library.

For all thing UNICODE you can go to the official UNICODE site.
I can not open my previous post so I start another one. Sorry for any inconvenience. :-)

I am not programming with GUI, so I can not use QT. The unicode official web site is very informative -- but I am going to find dedicated deucation tutorials for C/C++ programming, the web site only deals with general concepts of unicode.

Do you have any good materials to recommend?


regards,
George
 
Old 05-02-2006, 07:10 AM   #5
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thanks MichaelZ


Quote:
Originally Posted by MichaelZ
Hello,

Give also a look at:

www.wxWidgets.org

Best wishes,
Michael
The web site is dealing with GUI programming. Does it have any relationship with my question? :-)


regards,
George
 
Old 05-02-2006, 08:04 AM   #6
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by George2
I am not programming with GUI, so I can not use QT.
You can still use Qt, it has a switch to allow you to ignore the GUI libraries see

That way you can use the QString class that supports UNICODE without having to bundle all the GUI libraries with your application.

The difficulty with UNICODE programming is that C++ supports wide characters but these tend to be in a different format to how UNICODE is stored on disk. So the typical process is, read it in, convert it, do something (such as display on the terminal), convert back, write to file. It really is quite messy and so I strongly urge you to look for a wrapper class that manages that all for you.

As I said Qt is one solution (which maps across multiple O/S) but there are probably others out there.
 
Old 05-02-2006, 02:38 PM   #7
MichaelZ
Member
 
Registered: Mar 2006
Location: Austria
Distribution: Ubuntu Breezy 5.10
Posts: 32

Rep: Reputation: 15
Quote:
Originally Posted by George2
Thanks MichaelZ




The web site is dealing with GUI programming. Does it have any relationship with my question? :-)


regards,
George
Not only . WxWidgets is more than a GUI library. Have a look at wxBase:

Quote:
wxBase is a library for programming non-GUI (console) applications using the base wxWidgets functionality.
Best wishes,
Michael
 
Old 05-08-2006, 02:27 AM   #8
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thanks you graemef!


Quote:
Originally Posted by graemef
You can still use Qt, it has a switch to allow you to ignore the GUI libraries see

That way you can use the QString class that supports UNICODE without having to bundle all the GUI libraries with your application.

The difficulty with UNICODE programming is that C++ supports wide characters but these tend to be in a different format to how UNICODE is stored on disk. So the typical process is, read it in, convert it, do something (such as display on the terminal), convert back, write to file. It really is quite messy and so I strongly urge you to look for a wrapper class that manages that all for you.

As I said Qt is one solution (which maps across multiple O/S) but there are probably others out there.
I will consider QT, the only question is that, it will add footprint of my program.

Regarding the C++ UNICODE support, I am not quite sure what do you mean "but these tend to be in a different format to how UNICODE is stored on disk" and the conversion operations you mentioned afterwards. Could you show me an example please?


regards,
George
 
Old 05-08-2006, 02:42 AM   #9
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Hi MichaelZ,


Quote:
Originally Posted by MichaelZ
Not only . WxWidgets is more than a GUI library. Have a look at wxBase:



Best wishes,
Michael
I can only access www.WxWidgets.org, but can not find a dedicated introduction of wxBase. Could you provide an URL please?


regards,
George
 
Old 05-08-2006, 04:08 AM   #10
MichaelZ
Member
 
Registered: Mar 2006
Location: Austria
Distribution: Ubuntu Breezy 5.10
Posts: 32

Rep: Reputation: 15
Quote:
Originally Posted by George2
Hi MichaelZ,




I can only access www.WxWidgets.org, but can not find a dedicated introduction of wxBase. Could you provide an URL please?


regards,
George
Hello,

Unfortunately, it seems that there is not a lot of info about. I have found some info here and there, just by googling.

The best would be that you download it and look inside for some doc/examples. wxBase should be supported along wxGTK as it is a subpart of it.

Also useful would be the wxWidgets forums and mailing lists.

Here a free book about wxWidgets:

http://www.phptr.com/content/images/...73816_book.pdf

Best wishes,
Michael
 
Old 05-08-2006, 07:26 AM   #11
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by George2
"but these tend to be in a different format to how UNICODE is stored on disk" and the conversion operations you mentioned afterwards. Could you show me an example please?
As I remember C++ stores UNICODE internally (that is as variables) as a two byte char or w_char. However when it is stored on disk it can be stored as anything from a one byte to a four byte char. Essentially this is how the conversion goes, if the original character is from the original 7-bit ASCII character set then it will be stored on disk as a single byte with the left most bit set to zero. If the left most bit is not zero then it will be stored as a multi byte character, with some bits set aside to determine how many bytes are to be used and the rest to hold the actual data.

The reason for this it that internally to do sorts and comparisons it is easier if each character is of the same length, historically ASCII is the key encoding and so when storing these files on disk significant space can be saved if these can bas saved as single byte characters.

Take a look at UTF-8 & UNICODE FAQ
 
Old 05-08-2006, 08:26 AM   #12
spark.ty
LQ Newbie
 
Registered: Apr 2006
Distribution: gentoo
Posts: 3

Rep: Reputation: 0
Maybe this will help a bit: http://cprogramming.com/tutorial/unicode.html

Last edited by spark.ty; 05-08-2006 at 08:32 AM.
 
Old 05-11-2006, 04:42 AM   #13
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thank you spark.ty!


Quote:
Originally Posted by spark.ty
The tutorial is cool!


regards,
George
 
Old 05-11-2006, 04:51 AM   #14
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thank you MichaelZ!


Quote:
Originally Posted by MichaelZ
Hello,

Unfortunately, it seems that there is not a lot of info about. I have found some info here and there, just by googling.

The best would be that you download it and look inside for some doc/examples. wxBase should be supported along wxGTK as it is a subpart of it.

Also useful would be the wxWidgets forums and mailing lists.

Here a free book about wxWidgets:

http://www.phptr.com/content/images/...73816_book.pdf

Best wishes,
Michael
It seems a very comprehensive book.


regards,
George
 
Old 05-11-2006, 04:59 AM   #15
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Hi graemef,


Quote:
Originally Posted by graemef
As I remember C++ stores UNICODE internally (that is as variables) as a two byte char or w_char. However when it is stored on disk it can be stored as anything from a one byte to a four byte char. Essentially this is how the conversion goes, if the original character is from the original 7-bit ASCII character set then it will be stored on disk as a single byte with the left most bit set to zero. If the left most bit is not zero then it will be stored as a multi byte character, with some bits set aside to determine how many bytes are to be used and the rest to hold the actual data.
The theory is very useful. I am looking for some practical programming resources (tutorials) on the topics you mentioned above. Do you have any recommended ones?

Quote:
Originally Posted by graemef
The reason for this it that internally to do sorts and comparisons it is easier if each character is of the same length, historically ASCII is the key encoding and so when storing these files on disk significant space can be saved if these can bas saved as single byte characters.

Take a look at UTF-8 & UNICODE FAQ
Why comparison of the characters with the same length is faster than variable-length characters? I think it depends on how we implement the comparison algorithm. :-)

Why disk space is saved by "be saved if these can bas saved as single byte characters"? I think some characters are stored as single byte in unicode, but there are more characters which are stored as multiple bytes in unicode. Why disk space is saved?


reards,
Geroge
 
  


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
Programming in C Tutorial Mercurius Programming 22 05-08-2006 05:01 PM
Looking for C/C++ unicode related programming tutorial George2 Programming 1 05-01-2006 07:56 AM
glib programming tutorial (c) con Programming 3 12-16-2005 12:21 AM
looking for X programming tutorial (C or C++) qwijibow Programming 1 02-02-2004 08:33 AM

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

All times are GMT -5. The time now is 07:49 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