C++ (Qt) #include <iostream>#include <QTextCodec>#include <QObject>#include <QDebug> #define STR(s) ((QTextCodec::codecForLocale()->fromUnicode(s)).constData()) int main(){ qDebug() << QTextCodec::codecForLocale()->name(); std::cout << STR( QObject::tr( "Привет, Мир!" ) ); return 0;}
C++ (Qt)setlocale(LC_ALL, "rus");
C++ (Qt)#include "QCout.h"#include "QCin.h" int main(){ QCout qcout; QCin qcin; qcout << "Привет, Мир!" << qendl; return 0;}
C++ (Qt)#include "QCout.h" int main(){ QCout qcout; qcout.write( "Привет\n" ); return 0;}
C++ (Qt)#ifndef QCOUT_H#define QCOUT_H #include <string>#include <QTextStream>#include <QTextCodec> class QCout{public: QCout() { m_cout = new QTextStream( stdout ); m_codec = QTextCodec::codecForName( "CP866" ); m_cout->setCodec( m_codec ); } ~QCout() { delete m_cout; } void write( const std::string &text ) { QString qstrText( text.c_str( ) ); ( *m_cout ) << qstrText; ( *m_cout ).flush(); } private: QTextStream *m_cout; QTextCodec *m_codec;}; #endif // QCOUT_H