⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simple8impl.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.7平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    // to iso8859-11, so we name it 8859-11 here, but recognise the name tis620 too.    // $ for A in 8 9 A B C D E F ; do for B in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; do echo x${A}${B} 0xFFFD ; done ; done > /tmp/digits ; ( cut -c25- < TIS-620 ; cat /tmp/digits ) | awk '/^x[89ABCDEF]/{ print $1, $2 }' | sed -e 's/<U/0x/' -e 's/>//' | sort | uniq -w4 | cut -c5- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/tis-620    { "ISO 8859-11", 2259, // Thai character set mib enum taken from tis620 (which is byte by byte equivalent)        { 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,              0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,              0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,              0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,              0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07,              0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,              0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17,              0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,              0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,              0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,              0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,              0x0E38, 0x0E39, 0x0E3A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x0E3F,              0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,              0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,              0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,              0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} },    // change LAST_MIB if you add more, and edit unicodevalues in    // kernel/qpsprinter.cpp too.};static const QSimpleTextCodec * reverseOwner = 0;static QArray<char> * reverseMap = 0;QSimpleTextCodec::QSimpleTextCodec( int i )    : QTextCodec(), forwardIndex( i ){}QSimpleTextCodec::~QSimpleTextCodec(){    if ( reverseOwner == this ) {        delete reverseMap;        reverseMap = 0;        reverseOwner = 0;    }}QString QSimpleTextCodec::toUnicode(const char* chars, int len) const{    if ( len <= 0 || chars == 0 )        return QString::null;    const unsigned char * c = (const unsigned char *)chars;    int i;    for ( i = 0; i < len; i++ ) {	if ( c[i] == '\0' )	    len = i;    }    QString r;    r.setUnicode(0, len);    QChar* uc = (QChar*)r.unicode(); // const_cast    for ( i = 0; i < len; i++ ) {	if ( c[i] > 127 )            uc[i] = unicodevalues[forwardIndex].values[c[i]-128];	else            uc[i] = c[i];    }    return r;}QCString QSimpleTextCodec::fromUnicode(const QString& uc, int& len ) const{    if ( reverseOwner != this ) {        int m = 0;        int i = 0;        while( i < 128 ) {            if ( unicodevalues[forwardIndex].values[i] > m &&                 unicodevalues[forwardIndex].values[i] < 0xfffd )                m = unicodevalues[forwardIndex].values[i];            i++;        }        m++;        if ( !reverseMap )            reverseMap = new QArray<char>( m );        if ( m > (int)(reverseMap->size()) )            reverseMap->resize( m );        for( i = 0; i < 128 && i < m; i++ )            (*reverseMap)[i] = (char)i;        for( ;i < m; i++ )            (*reverseMap)[i] = '?';	// small hack to map nbsp to space for all simple codecs. Looks way better than a question mark.	(*reverseMap)[0xa0] = ' ';        for( i=128; i<256; i++ ) {            int u = unicodevalues[forwardIndex].values[i-128];            if ( u < m )                (*reverseMap)[u] = (char)(unsigned char)(i);        }        reverseOwner = this;    }    if ( len <0 || len > (int)uc.length() )        len = uc.length();    QCString r( len+1 );    int i = len;    int u;    const QChar* ucp = uc.unicode();    char* rp = r.data();    char* rmp = reverseMap->data();    int rmsize = (int) reverseMap->size();    while( i-- )    {        u = ucp->unicode();        *rp++ = u < 128 ? u : (( u < rmsize ) ? (*(rmp+u)) : '?' );        ucp++;    }    r[len] = 0;    return r;}const char* QSimpleTextCodec::name() const{    return unicodevalues[forwardIndex].cs;}int QSimpleTextCodec::mibEnum() const{    return unicodevalues[forwardIndex].mib;}int QSimpleTextCodec::heuristicNameMatch(const char* hint) const{    if ( hint[0]=='k' ) {        // Help people with messy fonts        if ( QCString(hint) == "koi8-1" )            return QTextCodec::heuristicNameMatch("koi8-r")-1;        if ( QCString(hint) == "koi8-ru" )            return QTextCodec::heuristicNameMatch("koi8-r")-1;    } else if ( hint[0] == 't' && QCString(name()) == "ISO 8859-11" ) {	// 8859-11 and tis620 are byte by bute equivalent	int i = simpleHeuristicNameMatch("tis620-0", hint);	if( !i )	    i = simpleHeuristicNameMatch("tis-620", hint);	if( i ) return i;    } else if (( hint[0]=='m' ) && ( QCString(hint) == "microsoft-cp1251" ))         return QTextCodec::heuristicNameMatch("cp1251");    else if (( hint[0]=='w' ) && ( QCString(hint) == "windows-1251" )) // No tr         return QTextCodec::heuristicNameMatch("cp1251")-1;    return QTextCodec::heuristicNameMatch(hint);}int QSimpleTextCodec::heuristicContentMatch(const char* chars, int len) const{    if ( len<1 || !chars )        return -1;    int i = 0;    const uchar * c = (const unsigned char *)chars;    int r = 0;    while( i<len && c && *c ) {        if ( *c >= 128 ) {            if ( unicodevalues[forwardIndex].values[(*c)-128] == 0xfffd )                return -1;        }        if ( (*c >= ' ' && *c < 127) ||             *c == '\n' || *c == '\t' || *c == '\r' )            r++;        i++;        c++;    }    if ( mibEnum()==4 )        r+=1;    return r;}Simple8Impl::Simple8Impl()    : ref(0){}Simple8Impl::~Simple8Impl(){}QStringList Simple8Impl::names() const{    QStringList r;    int i=0;    do {	r.append(unicodevalues[i].cs);    } while ( unicodevalues[i++].mib != LAST_MIB );    return r;}QTextCodec *Simple8Impl::createForName( const QString &name ){    int i=0;    do {	if ( name == unicodevalues[i].cs )	    return new QSimpleTextCodec(i);    } while ( unicodevalues[i++].mib != LAST_MIB );    return 0;}    QValueList<int> Simple8Impl::mibEnums() const{    QValueList<int> r;    int i=0;    do {        r.append(unicodevalues[i].mib);    } while ( unicodevalues[i++].mib != LAST_MIB );    return r;}QTextCodec *Simple8Impl::createForMib( int mib ){    int i=0;    do {	if ( mib == unicodevalues[i].mib )	    return new QSimpleTextCodec(i);    } while ( unicodevalues[i++].mib != LAST_MIB );    return 0;}#ifndef QT_NO_COMPONENTQRESULT Simple8Impl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ){    *iface = 0;    if ( uuid == IID_QUnknown )	*iface = this;    else if ( uuid == IID_QtopiaTextCodec )	*iface = this;    if ( *iface )	(*iface)->addRef();    return (*iface) ? QS_OK : QS_FALSE;}Q_EXPORT_INTERFACE(){    Q_CREATE_INSTANCE( Simple8Impl )}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -