Created
November 19, 2023 17:01
-
-
Save proffix4/55ec235d8a4179d062cf34067d60e752 to your computer and use it in GitHub Desktop.
Console UTF-8 application with boost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma execution_character_set( "utf-8" ) // for MSVC | |
#include <boost/nowide/args.hpp> // for utf8_to_utf16 | |
#include <boost/nowide/fstream.hpp> // for fstream | |
#include <boost/nowide/iostream.hpp> // for cout, cerr, cin, clog | |
using namespace boost::nowide; // for cout, cerr, cin, clog | |
using std::endl; // for endl | |
int main() | |
{ | |
//system("chcp 65001"); | |
std::locale::global(std::locale("En-us.UTF-8")); // for MSVC | |
cout << "Testing unicode -- English -- Ελληνικά -- Español -- Русский. aäbcdefghijklmnoöpqrsßtuüvwxyz\n"; | |
std::string fio; // = "Иванов Иван Иванович"; | |
cout << "Введите строку: "; | |
cin >> fio; | |
cout << "Вы ввели: " << fio << "\n"; | |
cout << "Размер строки: " << fio.length() << endl; | |
for (int i = 0; i < fio.length(); ++i) { | |
cout << "[" << i << "]" << fio[i] << " (code: " << int(fio[i]) << ")" << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Реально рабочий код для решения проблем с UTF-8 для Windows и компилятора MS!