Created
November 21, 2023 07:01
-
-
Save proffix4/76e84fa0989917fe50a9f4d7dc3d1368 to your computer and use it in GitHub Desktop.
Cpp UTF8 Cross - platform program
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
#include <stdlib.h> | |
#include <iostream> | |
#ifdef _WIN32 // Если это Windows | |
#include <io.h> | |
#include <fcntl.h> | |
#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 input; // Создать строковую переменную | |
std::wcin >> input; // Считать строку | |
std::wcout << L"Привет, " << input << "!" << std::endl; // Вывести строку | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
файл нужно сохранить в кодировке UTF-8 с cигнатурой BOM !