Как вывести в консоль русские буквы?
Подключаем locale.h, в коде пишем setlocale(LC_ALL, "rus");
#include <stdio.h> #include <locale.h> int main() { setlocale( LC_ALL, "rus"); printf( "%s", "Привет, мир!"); return 0; }
Cредствами с++:
#include <iostream> #include <locale> int main() { std::locale rus( "rus_rus.866"); std::wcout.imbue( rus); std::wcout << L"Привет, мир!!!"; return 0; }
Для Delphi
function Rus(mes: string):string; // В ANSI русские буквы кодируются числами от 192 до 255, // в ASCII - от 128 до 175 (А..Яа..п) и от 224 до 239 (р..я). var i: integer; // номер обрабатываемого символа begin SetLength(Result,length(mes)); for i:=1 to length(mes) do case mes[i] of 'А'..'п' :Result[i] := Chr(Ord(mes[i]) - 64); 'р'..'я' :Result[i] := Chr (Ord(mes [i] ) -16); else Result[i]:=mes[i]; end; end;
7 января 2008 (Обновление: 28 фев 2008)