我正在研究乌尔都语印地语翻译/音译。我的目标是将乌尔都语句子翻译成印地语,反之亦然,我正在使用 Visual c++ 2010 软件和 c++ 语言。我在保存为 UTF-8 格式的文本文件中写了一个乌尔都语句子。现在我想从该文件中一个一个地获取单个字符,以便我可以处理它以将其转换为等效的印地语字符。当我尝试从输入文件中获取单个字符并将该单个字符写入输出文件时,我在输出文件中得到了一些不知名的丑陋字符。请帮助我正确的代码。我的代码如下
#include<iostream>
#include<fstream>
#include<cwchar>
#include<cstdlib>
using namespace std;
void main()
{
wchar_t arry[50];
wifstream inputfile("input.dat",ios::in);
wofstream outputfile("output.dat");
if(!inputfile)
{
cerr<<"File not open"<<endl;
exit(1);
}
while (!inputfile.eof()) // i am using this while just to
// make sure copy-paste operation of
// written urdu text from one file to
// another when i try to pick only one character
// from file, it does not work.
{ inputfile>>arry; }
int i=0;
while(arry[i] != '\0') // i want to get urdu character placed at
// each-index so that i can work on it to convert
// it into its equivalent hindi character
{ outputfile<<arry[i]<<endl;
i++; }
inputfile.close();
outputfile.close();
cout<<"Hello world"<<endl;
}