Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 16th, 2008, 8:04 AM   #1
whizzkid
Newbie
 
Join Date: Feb 2008
Posts: 12
Rep Power: 0 whizzkid is on a distinguished road
C++ and Unicode support

First of all - hello everybody

I am currently working on program that conjugates and words in various languages. Everything goes ok, but my problems started with diacritics (national letters).

I am using CPP Builder 6.0 for designing window interface, but problems began also when programming command line program. Of course the problem concerns Unicode coding. I need some to way to read Unicode characters from file, then perform actions on them and finally, display.

I must admit I am not hard-science mind, my experiences are quite modest in this field, as well as in programming in general. I have been looking for weeks for comprehensive sources for Unicode issue, but they provide only theoretical or complicated practical guides, which are beyond my understanding.

What I would like to ask you, Great Community: can you explain me in very easy way (example would be nicely seen) how to deal with the problem? I mean a several-line program that reads various characters and displays them? Telling me to use libiconv or stdstring etc. woulb be a total abstraction for me.

Any help would be greatly appreciated

Thanks in forward

PS. Since there are various Unicode formats: I need to use only latin-extended, cyrylic and greek alphabets, all in left-to-right format.
whizzkid is offline   Reply With Quote
Old Feb 16th, 2008, 6:44 PM   #2
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 432
Rep Power: 9 Narue is on a distinguished road
Re: C++ and Unicode support

>can you explain me in very easy way (example would
>be nicely seen) how to deal with the problem?
Given your restrictions, you can do this relatively easily depending on what you mean by "then perform actions on them". Here's a simple program that reads a Windows file with the default Unicode encoding (UTF-16 little endian) and copies it character by character. Provided your standard library correctly converts between UTF-16LE and C++ wide characters, you're good:
c++ Syntax (Toggle Plain Text)
  1. #include <stdio.h>
  2. #include <wchar.h>
  3.  
  4. int main ( void )
  5. {
  6. FILE *in = fopen ( "test.txt", "r,ccs=UNICODE" );
  7. FILE *out = fopen ( "output.txt", "r,ccs=UNICODE" );
  8. wchar_t ch;
  9.  
  10. while ( ( ch = fgetwc ( in ) ) != WEOF ) {
  11. /* Process a UTF-16LE character */
  12. fputwc ( ch, out );
  13. }
  14.  
  15. return 0;
  16. }
I say this because Latin Extended, Cyrillic, and Greek are all supported by Windows' Unicode fonts. This program will copy the Unicode file (be sure to save the input file as Unicode first). Each wide character will be a 16-bit entity with the code point for your character because Latin Extended, Cyrillic, and Greek are all in the Basic Multilingual Plane.

However, don't waste your time with the console. The Windows console is notoriously bad at correctly handling Unicode characters, even if you use the Lucida Console font. You'll just spend countless hours trying to troubleshoot code that works perfectly with a suitable display application.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Feb 17th, 2008, 3:20 AM   #3
whizzkid
Newbie
 
Join Date: Feb 2008
Posts: 12
Rep Power: 0 whizzkid is on a distinguished road
Re: C++ and Unicode support

Quote:
Originally Posted by Narue View Post
be sure to save the input file as Unicode first
Hmm, so the only thing I need is text editor that is able to save text in UTF-16, yup? It's a pity Notepad++ does not support it, but that's a minor problem. Thank you very much for your help

But I would like to ask about one more small thing. I am coding in CPP Builder 6.0 and I cannot make buttons with certain characters, as well as fill text fields or generally paste them into code. Is there an external program I shall use to "update" my sourcecode?
whizzkid is offline   Reply With Quote
Old Feb 17th, 2008, 6:04 AM   #4
Ancient Dragon
Achieved Level 70

 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 4,345
Rep Power: 10 Ancient Dragon will become famous soon enoughAncient Dragon will become famous soon enough
Re: C++ and Unicode support

>>It's a pity Notepad++ does not support it
It probably does if you have the language(s) installed on your computer.

>>I am coding in CPP Builder 6.0
Why don't you get a newer compiler that allows you to do that ?
Ancient Dragon is offline   Reply With Quote
Old Feb 17th, 2008, 6:05 AM   #5
whizzkid
Newbie
 
Join Date: Feb 2008
Posts: 12
Rep Power: 0 whizzkid is on a distinguished road
Re: C++ and Unicode support

I thought is is the newest version of BCB. Is whole Borland CPP Builder out of date? So which one do you recommend?
whizzkid is offline   Reply With Quote
Old Feb 17th, 2008, 6:07 AM   #6
Ancient Dragon
Achieved Level 70

 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 4,345
Rep Power: 10 Ancient Dragon will become famous soon enoughAncient Dragon will become famous soon enough
Re: C++ and Unicode support

I don't use it myself, but here's the Link
Ancient Dragon is offline   Reply With Quote
Old Feb 17th, 2008, 8:14 AM   #7
whizzkid
Newbie
 
Join Date: Feb 2008
Posts: 12
Rep Power: 0 whizzkid is on a distinguished road
Re: C++ and Unicode support

Quote:
Originally Posted by Ancient Dragon View Post
I don't use it myself, but here's the Link
I got free 6.0. I cannot afford BCB 2007. I don't want to steal...
whizzkid is offline   Reply With Quote
Old Feb 17th, 2008, 8:30 AM   #8
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 432
Rep Power: 9 Narue is on a distinguished road
Re: C++ and Unicode support

>I cannot afford BCB 2007.
Try something free and modern then.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Feb 17th, 2008, 11:36 AM   #9
whizzkid
Newbie
 
Join Date: Feb 2008
Posts: 12
Rep Power: 0 whizzkid is on a distinguished road
Re: C++ and Unicode support

Ok thaks, I will try then
whizzkid is offline   Reply With Quote
Old Feb 17th, 2008, 7:34 PM   #10
Ancient Dragon
Achieved Level 70

 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 4,345
Rep Power: 10 Ancient Dragon will become famous soon enoughAncient Dragon will become famous soon enough
Re: C++ and Unicode support

There are at least two other free modern compilers too, like Dev-C++ and VC++ 2008 Express
Ancient Dragon is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:46 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC