add sample and alternative encoding names

This commit is contained in:
Günter Obiltschnig 2018-02-14 09:49:28 +01:00
parent 37b0c377a9
commit 11d91b663d
9 changed files with 15195 additions and 15107 deletions

View File

@ -0,0 +1 @@
add_subdirectory(TextConverter)

View File

@ -0,0 +1,10 @@
#
# Makefile
#
# Makefile for Poco Encodings Samples
#
.PHONY: projects
clean all: projects
projects:
$(MAKE) -C TextConverter $(MAKECMDGOALS)

View File

@ -0,0 +1,7 @@
set(SAMPLE_NAME "TextConverter")
set(LOCAL_SRCS "")
aux_source_directory(src LOCAL_SRCS)
add_executable( ${SAMPLE_NAME} ${LOCAL_SRCS} )
target_link_libraries( ${SAMPLE_NAME} PocoEncodings PocoFoundation )

View File

@ -0,0 +1,15 @@
#
# Makefile
#
# Makefile for Poco TextConverter
#
include $(POCO_BASE)/build/rules/global
objects = TextConverter
target = TextConverter
target_version = 1
target_libs = PocoEncodings PocoFoundation
include $(POCO_BASE)/build/rules/exec

View File

@ -0,0 +1,51 @@
//
// 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;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff