In C ++, I have a text file that contains Arabic text, for example:
شكلك بتعرف تقرأ عربي يا ابن الذين
and I want to analyze each line of this file in a line and use string functions on it (e.g. substr, length, at ... etc.), and then print some parts of it into the output file.
I tried to do this, but it prints some garbage characters, such as "\ c7 \ 'e1 \' de \ 'd1 \" Is there a library to support Arabic characters?
edit: just add the code:
#include <iostream> #include <fstream> using namespace std; int main(){ ifstream ip; ip.open("d.rtf"); if(ip.is_open() != true){ cout<<"open failed"<<endl; return 0; } string l; while(!ip.eof()){ getline(ip, l); cout<<l<<endl; } return 0; }
Note. I still need to add processing code, for example
if(l == "كلام بالعربي"){ string s = l.substr(0, 4); cout<<s<<" is what you are looking for"<<endl; }
Csawy source share