LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Looking for C/C++ unicode related programming tutorial (https://www.linuxquestions.org/questions/programming-9/looking-for-c-c-unicode-related-programming-tutorial-440728/)

George2 05-01-2006 09:51 PM

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

graemef 05-01-2006 10:02 PM

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.

MichaelZ 05-02-2006 03:44 AM

Hello,

Give also a look at:

www.wxWidgets.org

Best wishes,
Michael

George2 05-02-2006 07:08 AM

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

George2 05-02-2006 07:10 AM

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

graemef 05-02-2006 08:04 AM

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.

MichaelZ 05-02-2006 02:38 PM

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

George2 05-08-2006 02:27 AM

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

George2 05-08-2006 02:42 AM

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

MichaelZ 05-08-2006 04:08 AM

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

graemef 05-08-2006 07:26 AM

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

spark.ty 05-08-2006 08:26 AM

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

George2 05-11-2006 04:42 AM

Thank you spark.ty!


Quote:

Originally Posted by spark.ty

The tutorial is cool!


regards,
George

George2 05-11-2006 04:51 AM

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

George2 05-11-2006 04:59 AM

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


All times are GMT -5. The time now is 10:39 PM.