X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=examples%2Ftranscode.cpp;fp=examples%2Ftranscode.cpp;h=3f4121da9add1ae58ac472aeae78bde78542e0fe;hp=0000000000000000000000000000000000000000;hb=628d762fbfd512aedde6f313f66594291dad4eb1;hpb=e240e074ce15c17d644e378067c2941aefcd5611 diff --git a/examples/transcode.cpp b/examples/transcode.cpp new file mode 100644 index 0000000..3f4121d --- /dev/null +++ b/examples/transcode.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +using namespace std; +using namespace Msp; + +int main(int argc, char **argv) +{ + if(argc<3) + { + cerr<<"Usage: "< \n"; + return 1; + } + + StringCodec::Codec *from = StringCodec::create_codec(argv[1]); + StringCodec::Codec *to = StringCodec::create_codec(argv[2]); + + StringCodec::Decoder *from_dec = from->create_decoder(); + StringCodec::Encoder *to_enc = to->create_encoder(); + + string line; + while(getline(cin, line)) + { + line += '\n'; + StringCodec::ustring ustr; + from_dec->decode(line, ustr); + string result; + to_enc->encode(ustr, result); + cout<sync(result); + cout<