You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.0 KiB
46 lines
1.0 KiB
15 years ago
|
#include "qutf7codec.h"
|
||
|
#include "qutf7codec.cpp"
|
||
15 years ago
|
#include <tqtextstream.h>
|
||
15 years ago
|
#include <string.h>
|
||
|
#include <assert.h>
|
||
14 years ago
|
#include <iostream>
|
||
15 years ago
|
|
||
|
int main( int argc, char * argv[] ) {
|
||
|
if ( argc == 1 ) {
|
||
14 years ago
|
(void)new TQUtf7Codec;
|
||
15 years ago
|
|
||
15 years ago
|
TQTextCodec * codec = TQTextCodec::codecForName("utf-7");
|
||
15 years ago
|
assert(codec);
|
||
|
|
||
15 years ago
|
TQTextIStream my_cin(stdin);
|
||
15 years ago
|
|
||
15 years ago
|
TQTextOStream my_cout(stdout);
|
||
15 years ago
|
my_cout.setCodec(codec);
|
||
|
|
||
15 years ago
|
TQString buffer = my_cin.read();
|
||
15 years ago
|
|
||
|
// qDebug("buffer == " + buffer);
|
||
|
|
||
|
#ifdef USE_STREAM
|
||
|
my_cout << buffer << endl;
|
||
|
#else
|
||
15 years ago
|
TQTextEncoder * enc = codec->makeEncoder();
|
||
15 years ago
|
#ifdef CHAR_WISE
|
||
|
int len;
|
||
|
for ( int i = 0 ; i < buffer.length() ; i++ ) {
|
||
|
len = 1;
|
||
15 years ago
|
cout << (enc->fromUnicode(TQString(buffer[i]),len)).data();
|
||
15 years ago
|
}
|
||
14 years ago
|
std::cout << std::endl;
|
||
15 years ago
|
#else
|
||
|
int len = buffer.length();
|
||
14 years ago
|
std::cout << (enc->fromUnicode(buffer,len)).data() << std::endl;;
|
||
15 years ago
|
#endif // CHAR_WISE
|
||
|
delete enc;
|
||
|
#endif // else USE_STREAM
|
||
|
} else {
|
||
|
qWarning("usage: testutf7encoder2 < infile > outfile\n");
|
||
|
}
|
||
15 years ago
|
TQTextCodec::deleteAllCodecs();
|
||
15 years ago
|
}
|