1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-19 12:07:13 +01:00
Sandu Liviu Catalin 4a6bfc086c Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface.
Deprecated the external module API. It was creating more problems than solving.
Removed most built-in libraries in favor of system libraries for easier maintenance.
Cleaned and secured code with help from static analyzers.
2021-01-30 08:51:39 +02:00

52 lines
1.1 KiB
C++

//
// TextConverter.cpp
//
// This sample demonstrates the text encodings support in POCO.
//
// Copyright (c) 2018, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/StreamConverter.h"
#include "Poco/StreamCopier.h"
#include "Poco/TextEncoding.h"
#include "Poco/Encodings.h"
#include <iostream>
inline int usage()
{
std::cout << "Usage: TextConverter <inEncoding> <outEncoding>" << std::endl;
return 1;
}
int main(int argc, char** argv)
{
if (argc < 3) return usage();
try
{
Poco::registerExtraEncodings(); // register encodings from the PocoEncodings library
std::string inEncodingName(argv[1]);
std::string outEncodingName(argv[2]);
Poco::TextEncoding& inEncoding = Poco::TextEncoding::byName(inEncodingName);
Poco::TextEncoding& outEncoding = Poco::TextEncoding::byName(outEncodingName);
Poco::OutputStreamConverter conv(std::cout, inEncoding, outEncoding);
Poco::StreamCopier::copyStream(std::cin, conv);
}
catch (Poco::Exception& exc)
{
std::cerr << exc.displayText() << std::endl;
return 2;
}
return 0;
}