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

📄 qjpunicode.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the plugins of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************//*! \class QJpUnicodeConv    \reentrant    \internal*/#include "qjpunicode.h"#include "qbytearray.h"#ifdef Q_OS_TEMP#include "qwinfunctions_wce.h"#endif#include <stdlib.h>#define        USE_JISX0212#define        Q_STRICT#define        IsLatin(c)        (/*((c) >= 0x00) &&*/ ((c) <= 0x7f))#define        IsKana(c)        (((c) >= 0xa1) && ((c) <= 0xdf))#define        IsJisChar(c)        (((c) >= 0x21) && ((c) <= 0x7e))#define        IsSjisChar1(c)        ((((c) >= 0x81) && ((c) <= 0x9f)) ||        \                         (((c) >= 0xe0) && ((c) <= 0xfc)))#define        IsSjisUDC1(c)        (((c) >= 0xf0) && ((c) <= 0xfc))#define        IsSjisChar2(c)        (((c) >= 0x40) && ((c) != 0x7f) && ((c) <= 0xfc))#define        IsSjisIBMVDCChar1(c)        (((c) >= 0xfa) && ((c) <= 0xfc))static uint jisx0208ToSjis(uint h, uint l);staticinline uint jisx0208ToSjis(uint jis){    return jisx0208ToSjis((jis & 0xff00) >> 8, (jis & 0x00ff));}static uint sjisToJisx0208(uint h, uint l);#if 0staticinline uint sjisToJisx0208(uint sjis){    return sjisToJisx0208((sjis & 0xff00) >> 8, (sjis & 0x00ff));}#endifstatic uint jisx0201ToUnicode11(uint h, uint l);static uint jisx0208ToUnicode11(uint h, uint l);static uint jisx0212ToUnicode11(uint h, uint l);static uint unicode11ToJisx0201(uint h, uint l);static uint unicode11ToJisx0208(uint h, uint l);static uint unicode11ToJisx0212(uint h, uint l);/* * Unicode 1.1 conversion. *//*!  \fn QJpUnicodeConv::QJpUnicodeConv (int r)  \internal*//*! \internal */uint QJpUnicodeConv::asciiToUnicode(uint h, uint l) const{    if ((h == 0) && (l < 0x80)) {        return l;    }    return 0x0000;}/*! \internal */uint QJpUnicodeConv::jisx0201ToUnicode(uint h, uint l) const{    if (h == 0) {        if (IsLatin(l)) {            return jisx0201LatinToUnicode(h, l);        } else if (IsKana(l)) {            return jisx0201KanaToUnicode(h, l);        }    }    return 0x0000;}/*! \internal */uint QJpUnicodeConv::jisx0201LatinToUnicode(uint h, uint l) const{    if ((h == 0) && IsLatin(l)) {        return jisx0201ToUnicode11(h, l);    }    return 0x0000;}/*! \internal */uint QJpUnicodeConv::jisx0201KanaToUnicode(uint h, uint l) const{    if ((h == 0) && IsKana(l)) {        return jisx0201ToUnicode11(h, l);    }    return 0x0000;}/*! \internal */uint QJpUnicodeConv::jisx0208ToUnicode(uint h, uint l) const{    if (rule & UDC){        if ((0x75 <= h) && (h <= 0x7e) && IsJisChar(l)/*0x21 - 0x7e*/) {            // User Defined Char (mapped to Private Use Area)            return 0xe000 + (h - 0x75) * 0x5e + (l - 0x21);        }    }    if ((rule & NEC_VDC) == 0) {        if ((h == 0x2d) && (IsJisChar(l)/*0x21 - 0x7c*/)) {            // NEC Vendor Defined Char            return 0x0000;        }    }    return jisx0208ToUnicode11(h, l);}/*! \internal */uint QJpUnicodeConv::jisx0212ToUnicode(uint h, uint l) const{    if (rule & UDC){        if ((0x75 <= h) && (h <= 0x7e) && IsJisChar(l)/*0x21 - 0x7e*/) {            // User Defined Char (mapped to Private Use Area)            return 0xe3ac + (h - 0x75) * 0x5e + (l - 0x21);        }    }    if ((rule & IBM_VDC) == 0){        if (((h == 0x73) && (0x73 <= l) && (l <= 0x7e)) ||            ((h == 0x74) && (IsJisChar(l)/*0x21 - 0x7e*/))) {            // IBM Vendor Defined Char            return 0x0000;        }    }    return jisx0212ToUnicode11(h, l);}/*! \internal */uint QJpUnicodeConv::unicodeToAscii(uint h, uint l) const{    if ((h == 0) && (l < 0x80)) {        return l;    }    return 0x0000;}/*! \internal */uint QJpUnicodeConv::unicodeToJisx0201(uint h, uint l) const{    uint jis;    if ((jis = unicodeToJisx0201Latin(h, l)) != 0) {        return jis;    } else if ((jis = unicodeToJisx0201Kana(h, l)) != 0) {        return jis;    }    return 0x0000;}/*! \internal */uint QJpUnicodeConv::unicodeToJisx0201Latin(uint h, uint l) const{    uint jis = unicode11ToJisx0201(h, l);    if (IsLatin(jis)) {        return jis;    }    return 0x0000;}/*! \internal */uint QJpUnicodeConv::unicodeToJisx0201Kana(uint h, uint l) const{    uint jis = unicode11ToJisx0201(h, l);    if (IsKana(jis)) {        return jis;    }    return 0x0000;}/*! \internal */uint QJpUnicodeConv::unicodeToJisx0208(uint h, uint l) const{    if (rule & UDC){        uint unicode = (h << 8) | l;        if ((0xe000 <= unicode) && (unicode <= 0xe3ab)) {            // User Defined Char (mapped to Private Use Area)            unicode -= 0xe000;            return ((0x75 + unicode / 0x5e) << 8) | (0x21 + unicode % 0x5e);        }    }    uint jis = unicode11ToJisx0208(h, l);    if ((rule & NEC_VDC) == 0) {        if ((0x2d21 <= jis) && (jis <= 0x2d7c)) {            // NEC Vendor Defined Char            return 0x0000;        }    }    return jis;}/*! \internal */uint QJpUnicodeConv::unicodeToJisx0212(uint h, uint l) const{    if (rule & UDC){        uint unicode = (h << 8) | l;        if ((0xe3ac <= unicode) && (unicode <= 0xe757)) {            // User Defined Char (mapped to Private Use Area)            unicode -= 0xe3ac;            return ((0x75 + unicode / 0x5e) << 8) | (0x21 + unicode % 0x5e);        }    }    uint jis = unicode11ToJisx0212(h, l);    if ((rule & IBM_VDC) == 0){        if (((0x7373 <= jis) && (jis <= 0x737e)) ||            ((0x7421 <= jis) && (jis <= 0x747e))) {            // IBM Vendor Defined Char            return 0x0000;        }    }    return jis;}/*! \internal */uint QJpUnicodeConv::sjisToUnicode(uint h, uint l) const{    if (h == 0) {        return jisx0201ToUnicode(h, l);    } else if (IsSjisChar1(h) && IsSjisChar2(l)) {        return jisx0208ToUnicode(sjisToJisx0208(h, l));    }    return 0x0000;}/*! \internal */uint QJpUnicodeConv::unicodeToSjis(uint h, uint l) const{    uint jis;    if ((jis = unicodeToJisx0201(h, l)) != 0x0000) {        return jis;    } else if ((jis = unicodeToJisx0208(h, l)) != 0x0000) {        return jisx0208ToSjis(jis);    } else if ((jis = unicodeToJisx0212(h, l)) != 0x0000) {        return 0x0000;    }    return 0x0000;}/* * Unicode 1.1 with JISX0201 conversion. */class QJpUnicodeConv_Unicode_JISX0201 : public QJpUnicodeConv {public:    QJpUnicodeConv_Unicode_JISX0201(int r) : QJpUnicodeConv(r) {}//    uint AsciiToUnicode(uint h, uint l) const;//    uint Jisx0201ToUnicode(uint h, uint l) const;

⌨️ 快捷键说明

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