Commit 780d4a21 authored by Victor Yacovlev's avatar Victor Yacovlev

Win32: Fixed ANSI/OEM encoding for console tools

parent f6528637
......@@ -177,7 +177,13 @@ public:
if (mustShowHelpAndExit) {
if (splashScreen_)
splashScreen_->finish(0);
fprintf(stderr, "%s", qPrintable(manager->commandLineHelp()));
const QString msg = manager->commandLineHelp();
#ifdef Q_OS_WIN32
QTextCodec * codec = QTextCodec::codecForName("CP866");
fprintf(stderr, "%s", codec->fromUnicode(msg).constData());
#else
fprintf(stderr, "%s", msg.toLocal8Bit().data());
#endif
exit(0);
return;
}
......
......@@ -21,7 +21,7 @@ KumirCompilerToolPlugin::KumirCompilerToolPlugin()
: KPlugin()
, analizer_(nullptr)
, generator_(nullptr)
, useAnsiWindowsOutput_(false)
, useAnsiWindowsOutput_(true)
{
}
......@@ -30,11 +30,11 @@ KumirCompilerToolPlugin::acceptableCommandLineParameters() const
{
using ExtensionSystem::CommandLineParameter;
QList<CommandLineParameter> result;
result << CommandLineParameter(
false,
'a', "ansi",
tr("Show error messages in console using CP1251 encoding instead of CP866 (Windows only)")
);
// result << CommandLineParameter(
// false,
// 'a', "ansi",
// tr("Show error messages in console using CP1251 encoding instead of CP866 (Windows only)")
// );
result << CommandLineParameter(
false,
'e', "encoding",
......@@ -126,12 +126,7 @@ void KumirCompilerToolPlugin::start()
": " + e.code;
#ifdef Q_OS_WIN32
QTextCodec * cp866 = QTextCodec::codecForName("CP866");
if (useAnsiWindowsOutput_) {
std::cerr << cp866->fromUnicode(errorMessage).data();
}
else {
std::cerr << errorMessage.toLocal8Bit().data();
}
fprintf(stderr, "%s\n", cp866->fromUnicode(errorMessage).constData());
#else
std::cerr << errorMessage.toLocal8Bit().data();
#endif
......@@ -165,15 +160,10 @@ void KumirCompilerToolPlugin::start()
qApp->setProperty("returnCode", errors.isEmpty()? 0 : 1);
}
else {
const QString errorMessage = tr("Can't open file %1").arg(filename);
const QString errorMessage = tr("Can't open file %1").arg(QDir::toNativeSeparators(filename));
#ifdef Q_OS_WIN32
QTextCodec * cp866 = QTextCodec::codecForName("CP866");
if (useAnsiWindowsOutput_) {
std::cerr << cp866->fromUnicode(errorMessage).data();
}
else {
std::cerr << errorMessage.toLocal8Bit().data();
}
fprintf(stderr, "%s\n", cp866->fromUnicode(errorMessage).constData());
#else
std::cerr << errorMessage.toLocal8Bit().data();
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment