#include <qapplication.h>
#include <qtextcodec.h>
//------------------------------------------------------------------------
#include "TMainForm.h"
//------------------------------------------------------------------------
int main(int iArgc, char* iArgv[])
{
QApplication MyProgramme(iArgc, iArgv);
QTextCodec* pCodec = QTextCodec::codecForName("Utf8");
QTextCodec::setCodecForTr(pCodec);
QTextCodec::setCodecForCStrings(pCodec);
QTextCodec::setCodecForLocale(pCodec);
TMainForm* pMainWindow = new TMainForm;
MyProgramme.setMainWidget(pMainWindow);
pMainWindow->showMaximized();
return MyProgramme.exec();
}
#define BUF_SZ 8192
/* Special char codes */
#define BS 8
#define CR 13
#define LF 10
#define DOS_EOF 26 /* Ctrl-Z */
#define UNIX_EOF 4 /* Ctrl-D */
// ...
#define out(x) fputs(x,stdout) /* info */
#define outE(x) fputs(x,stdout) /* error */
// ...
unsigned char koi_table[TBL_SIZE] = {
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
238,160,161,230,164,165,228,163,229,168,169,170,171,172,173,174,
175,239,224,225,226,227,166,162,236,235,167,232,237,233,231,234,
158,128,129,150,132,133,148,131,149,136,137,138,139,140,141,142,
143,239,144,145,146,147,134,130,156,155,135,152,157,153,151, -1};
unsigned char win_table[TBL_SIZE] = {
0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0,
0, 96, 39, 34, 34,249, 45, 45, 0, 0, 0, 62, 0, 0, 0, 0,
0, 0, 0, 74,253, 0,124, 21,240, 0, 0, 17, 0,196, 0, 73,
248,241, 73,105, 39, 0, 20,250,241,252, 0, 16,106, 83,115,105,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239};
// и т.д.
unsigned char *table[] ={ NULL, koi_table, win_table, gost_table, bulg_table};
char *charset[] = { "Alt", "Koi8", "Win", "GOST", "Bulgar" };
enum { ALT, KOI, WIN, GOST, BULG }
charset_in, charset_out;
unsigned char buf_in[BUF_SZ], buf_out[BUF_SZ];
int used_in = BUF_SZ, pos_in = BUF_SZ, pos_out;
// ...
int char_in( void )
{
if ( pos_in >= used_in ) {
if( ( used_in = read( h1, buf_in, BUF_SZ ) ) <= 0 )
return -1;
pos_in = 0; }
return buf_in[ pos_in++ ];
}
//...
int ch, pred_ch = BS, pred_cr, bsoff, d2u = -1, over, comma;
char *src, *dest;
//...
/** do recoding **/
while( ( ch = char_in() ) >= 0 ) {
switch( d2u ) {
case 0:
if( ch == UNIX_EOF ) break;
if( ch == LF && !pred_cr ) putx(CR);
putx(ch);
pred_cr = ( ch == CR );
break;
case 1:
if( ch == DOS_EOF ) break;
if( ch != LF && pred_cr ) putx(CR);
if( ( pred_cr = ( ch == CR ) ) == 0 )
putx( ch );
break;
default:
putx(ch);
} /* switch */
} /* while */
#include <iconv.h>
size_t iconv(iconv_t cd,
char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft);
#include <iconv.h>
iconv_t iconv_open(const char *tocode, const char *fromcode);
QString QWindowsLocalCodec::toUnicode(const char* chars, int len) const
{
if ( len == 1 && chars ) { // Optimization; avoids allocation
char c[2];
c[0] = *chars;
c[1] = 0;
return qt_winMB2QString( c, 2 );
}
if ( len < 0 )
return qt_winMB2QString( chars );
QCString s(chars,len+1);
return qt_winMB2QString(s);
}
QCString QWindowsLocalCodec::fromUnicode(const QString& uc, int& lenInOut ) const
{
QCString r = qt_winQString2MB( uc, lenInOut );
lenInOut = r.length();
return r;
}
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.