Farsi character utf8 in c++

Viewed 1081

i m trying to read and write Farsi characters in c++ and i want to show them in CMD first thing i fix is Font i add Farsi Character to that and now i can write on the screen for example ب (uni : $0628) with this code:

#include <iostream>
#include <io.h>
#include <fcntl.h>
using namespace std;
int main() {
    _setmode(_fileno(stdout), _O_U16TEXT);
    wcout << L"\u0628 \n";
    wcout << L"ب"<<endl;
    system("pause");
} 

but how i can keep this character ... for Latin characters we can use char or string but how about Farsi character utf8 ?!

and how i can get them ... for Latin characters we use cin>>or gets_s

should i use wchar_t? if yes how? because with this code it show wrong character ...

wchar_t a='\u0628';
wcout <<a;

and i can't show this character بـ (uni $FE91) even though that exist in my installed font but ب (uni $0628) showed correctly

thanks in advance

1 Answers
Related