[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unicode Help
- To: Development Discussions <developer at arabeyes dot org>
- Subject: Re: Unicode Help
- From: Abdalla Alothman <abdalla at pheye dot net>
- Date: Wed, 31 Aug 2005 10:33:25 +0300
- Organization: Pheye Technologique, GT&C
- User-agent: KMail/1.8
Asalamu alaikum wa rahmatullaah
On Sunday 28 August 2005 13:08, zeeshan aslam wrote:
> I copy the simple program "To copy a single character to one file to
> another" is working correctly using english text data but not working when
> using arabic text data.
[...]
> int ch;
[...]
> ch=getc(fa);
> putc(ch,fb);
I assume it doesn't work because you are using an int representation
for a wide chararcter. I see that you are not using the characters in
any way; so why do you want to copy character by character instead of
word by word or line by line? Another problem might be with the document
format you are using.
> Questions:
> 1) Which Version of C++ is best?
If you mean what standard; the one you are using is very old.
Here is another way to accomplish your task using the current
deployed (there's a new standard, I hear, on the way) standard.
If you mean which compiler, I think the Intel compiler is the best.
The Microsoft people hired the best C++ experts to work on their
compiler, so it's also good. The GNU compiler is my favorite. You
can have it on windows as well (I think it's called DJGPP or something.)
// no .h in standard headers. <cstdlib>, <cstdio> if you want C headers
#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
//#include <cctype>
//#include <algorithm>
//#include <vector>
using namespace std;
int main() //not void main(void) :)
{
// Get the input file
ifstream inputfile("myInputFile.txt");
// Get an iterator that will iterate over strings
// in the input source
istream_iterator<string> inString(inputfile);
istream_iterator<string> fin;
ofstream outfile("myOutputFile.txt");
ostream_iterator<string> output(outfile, "\n");
//ostream_iterator<string> out(cout, "\n");
// vector to hold strings.
//vector<string> t;
while(inString != fin)
{
//You can have a string. Uncomment next line
//string s(*inString);
//*out++ = *inString;
*output++ = *inString++;
//and access its characters.
//Uncomment next statements and above statements and #includes
//transform(s.begin(), s.end(), s.begin(), ::toupper);
//t.push_back(s);
}
//copy(t.begin(), t.end(), ostream_iterator<string>(cout, "\n"));
return 0;
}
There are of course other convenient ways to do it, but I did that so
you can test whether your compiler adheres to the current standard.
> 2) How to use Unicode in C++ programming?
See: http://www.ibm.com/software/globalization/icu/
Also take a look at the excellent QT library:
http://www.trolltech.com
> 3) Other suggestion about it?
You might want to get a new C++ reference and spend some time with it.
(learn slowly, don't go fast.)
Wishing you and your family peace and good health. And good luck in your
studies.
Salam,
Abdalla Alothman