How Read Urdu text file and then write it to other file in c++

848 views Asked by At

I want to input a file containing Urdu words and write them in other file. The problem I'm facing is that Urdu language doesn't have spaces, so other file written would look alike all words joined to each other. How can i separate words or detect spaces ? My Code is this.

#include<iostream.h>
#include<conio.h>
#include<fstream.h>

void main()
{
    ifstream file;
    ofstream myfile;
    file.open ("urduwords.txt");     //File containing Urdu words
    myfile.open("urduoutput.txt");   // Output file
    if (!file.is_open()) return;

char * word= new char[];
        while(file>>word)
        {
            myfile<<word;
            // What to write here to separate words or detect spaces. Input file is saved in UTF-8
        }
myfile.close();
file.close();
cout<<"Check output"<<endl;
}
1

There are 1 answers

0
Moeen On

Oh I got answer. The answer is you have to put spaces between Urdu characters because Urdu language has Space Omission Problem so at while loop

while(file>>word)
        {
            myfile<<word;
            myfile<<" ";   // Put spaces between words. 
        }