An open API service indexing awesome lists of open source software.

https://github.com/tsnsoft/cpputf8crossplatform

Пример консольной кроссплатформенной программы на C++ с UTF-8 для Visual Studio 2022
https://github.com/tsnsoft/cpputf8crossplatform

console cpp cross-platform linux utf-8 visual-studio windows

Last synced: about 1 month ago
JSON representation

Пример консольной кроссплатформенной программы на C++ с UTF-8 для Visual Studio 2022

Awesome Lists containing this project

README

          

# CppUTF8CrossPlatform
Пример консольной кроссплатформенной программы на C++ с UTF-8 для Visual Studio 2022

![srcreenshot](screenshot.png)

```
#include
#include

#ifdef _WIN32 // Если это Windows
#include
#include
#endif

int main(int argc, char** argv)
{
setlocale(LC_ALL, "ru_RU.UTF-8"); // Установить русскую локаль для Linux

#ifdef _WIN32
_setmode(_fileno(stdout), _O_U16TEXT); // Установить Юникод для вывода в консоли Windows
_setmode(_fileno(stdin), _O_U16TEXT); // Установить Юникод для ввода в консоли Windows
_setmode(_fileno(stderr), _O_U16TEXT); // Установить Юникод для вывода ошибок в консоли Windows
#endif

std::wcout << L"Замечательно! Das ist großartig! Wonderful! 精彩的! رائع!\n";
std::wcout << L"Введите имя: ";
std::wstring fio; // Создать строковую переменную
std::wcin >> fio; // Считать строку
std::wcout << L"Привет, " << fio << "!" << std::endl; // Вывести строку
std::wcout << L"Размер строки: " << fio.length() << std::endl;
for (int i = 0; i < fio.length(); i++) {
std::wcout << "[" << i << "]: " << fio[i] << " (code: " << int(fio[i]) << ")" << std::endl;
}

}
```