My new code that prints to screen, in vs 2010 express c++:
Code:
#include <fcntl.h>
#include <io.h>
#include <cstdio>
#include <cwchar>
#include <iostream>
#include <fstream>
#include <locale>
#include <cstdlib> // exit()
using namespace std;
int main()
{
_setmode(_fileno(stdout), _O_U16TEXT);
// empty files
ofstream fout("file_out.txt");
fout.close();
// get user input.
ofstream holdInputSentence("file_out.txt");
if (!holdInputSentence) { cerr<<"file error\n"; exit(1); }
char inputSentence[4096];
wcout << L"Enter your sentence, end it with a period: ";
cin.getline (inputSentence,4096);
holdInputSentence << inputSentence;
holdInputSentence.close();
wifstream read_the_counter_file("file_out.txt");
wstring read_text;
wcout << L"\n";
while(read_the_counter_file >> read_text)
{
wcout << read_text << " ";
}
read_the_counter_file.close();
wcout << L"\n\n";
// I pause the console window so you can read the screen results
system ("pause");
}
My output for english works when I use raster font, but that asian font gets english all different symbols like hearts.
Here is my output for my test Chinese font using raster font:
Code:
Enter your sentence, end it with a period: 绽湛栈蘸菚颤张章彰璋漳樟蟑鄣獐嫜餦麞
粻鏱蔁騿掌鐣仉鞝涨障丈帐仗
?´ï?ÅÙ???³¹¹ü¼ýºs¼ÌÁ..ähº¼ák??ã^??ö¡´x?ÉSïA?»Ù¤V?¥M
Press any key to continue . . .
and using the asian font:
Code:
Enter your sentence, end it with a period: 绽湛栈蘸菚颤张章彰璋漳樟蟑鄣獐嫜餦麞
粻鏱蔁騿掌鐣仉鞝涨障丈帐仗
?´ï?ÅÙ???³¹¹ü¼ýºs¼ÌÁ..ähº¼ák??ã^??ö¡´x?ÉSïA?»Ù¤V?¥M
Press any key to continue . . .
when I tried with wcin this code I got numbers instead of text;
Code:
wchar_t inputSentence[4096];
cout << "Enter your sentence, end it with a period: ";
wcin.getline (inputSentence,4096);