/
wwwwd
/
my_telegram_bot
Обзор
Документация
Войти
/
wwwwd
/
my_telegram_bot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
main.cpp
69 строк
1 KB
Bogdan Khokhlov
Create C++ prototype using AI agent
18 июн 2026, 05:02
18 июн 2026, 05:02
e6a73c1
Код
Авторство
О чём код?
#include <algorithm> #include <cctype> #include <iostream> #include <string> #ifdef _WIN32 #include <windows.h> #endif std::string to_upper(const std::string& text) { if (text.empty()) { return text; } #ifdef _WIN32 const int wide_len = MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, nullptr, 0); if (wide_len <= 0) { return text; } std::wstring wide(static_cast<size_t>(wide_len - 1), L'\0'); MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, wide.data(), wide_len); for (wchar_t& ch : wide) { ch = towupper(ch); } const int utf8_len = WideCharToMultiByte( CP_UTF8, 0, wide.c_str(), -1, nullptr, 0, nullptr, nullptr); if (utf8_len <= 0) { return text; } std::string result(static_cast<size_t>(utf8_len - 1), '\0'); WideCharToMultiByte( CP_UTF8, 0, wide.c_str(), -1, result.data(), utf8_len, nullptr, nullptr); return result; #else std::string result = text; std::transform( result.begin(), result.end(), result.begin(), [](unsigned char ch) { return static_cast<char>(std::toupper(ch)); }); return result; #endif } int main() { #ifdef _WIN32 SetConsoleOutputCP(CP_UTF8); SetConsoleCP(CP_UTF8); #endif std::string line; while (true) { std::cout << "Введите сообщение: "; if (!std::getline(std::cin, line)) { break; } std::cout << to_upper(line) << std::endl; } return 0; }