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

📄 qjpunicode.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
uint QJpUnicodeConv_Sun::unicodeToJisx0212(uint h, uint l) const{#if 1    // Added by Serika Kususugawa to avoid conflict on U+007c.    if ((h == 0x00) && (l == 0x7e)) {        return 0x0000;    }    if ((h == 0xff) && (l == 0x5e)) {        return 0x2237;    }#endif    return QJpUnicodeConv::unicodeToJisx0212(h, l);}/* * Microsoft conversion. */class QJpUnicodeConv_Microsoft : public QJpUnicodeConv {public:    QJpUnicodeConv_Microsoft(int r) : QJpUnicodeConv(r) {}//    uint AsciiToUnicode(uint h, uint l) const;//    uint Jisx0201ToUnicode(uint h, uint l) const;    uint jisx0201LatinToUnicode(uint h, uint l) const;//    uint Jisx0201KanaToUnicode(uint h, uint l) const;    uint jisx0208ToUnicode(uint h, uint l) const;    uint jisx0212ToUnicode(uint h, uint l) const;//    uint UnicodeToAscii(uint h, uint l) const;//    uint UnicodeToJisx0201(uint h, uint l) const;    uint unicodeToJisx0201Latin(uint h, uint l) const;//    uint UnicodeToJisx0201Kana(uint h, uint l) const;    uint unicodeToJisx0208(uint h, uint l) const;    uint unicodeToJisx0212(uint h, uint l) const;};uint QJpUnicodeConv_Microsoft::jisx0201LatinToUnicode(uint h, uint l) const{    return asciiToUnicode(h, l);}uint QJpUnicodeConv_Microsoft::jisx0208ToUnicode(uint h, uint l) const{    if (h == 0x21) {        if (l == 0x40) {            return 0xff3c;        } else if (l == 0x41) {            return 0xff5e;        } else if (l == 0x42) {            return 0x2225;        } else if (l == 0x5d) {            return 0xff0d;        } else if (l == 0x71) {            return 0xffe0;        } else if (l == 0x72) {            return 0xffe1;        }    } else if (h == 0x22) {        if (l == 0x4c) {            return 0xffe2;        }    }    return QJpUnicodeConv::jisx0208ToUnicode(h, l);}uint QJpUnicodeConv_Microsoft::jisx0212ToUnicode(uint h, uint l) const{    if (h == 0x22) {        if (l == 0x37) {            return 0xff5e;        } else if (l == 0x43) {            return 0xffe4;        }    }    return QJpUnicodeConv::jisx0212ToUnicode(h, l);}uint QJpUnicodeConv_Microsoft::unicodeToJisx0201Latin(uint h, uint l) const{    return QJpUnicodeConv::unicodeToAscii(h, l);}uint QJpUnicodeConv_Microsoft::unicodeToJisx0208(uint h, uint l) const{#ifdef Q_STRICT    if (((h == 0x00) && ((l == 0x5c) || (l == 0xa2) || (l == 0xa3) || (l == 0xac))) ||        ((h == 0x20) && (l == 0x16)) ||        ((h == 0x22) && (l == 0x12)) ||        ((h == 0x30) && (l == 0x1c))) {        return 0x0000;    }#else    if ((h == 0x00) && (l == 0x5c)) {        return 0x0000;    }#endif    if ((h == 0x22) && (l == 0x25)) {        return 0x2142;    } else if (h == 0xff) {        if (l == 0x0d) {            return 0x215d;        } else if (l == 0xe0) {            return 0x2171;        } else if (l == 0xe1) {            return 0x2172;        } else if (l == 0xe2) {            return 0x224c;        }    }    return QJpUnicodeConv::unicodeToJisx0208(h, l);}uint QJpUnicodeConv_Microsoft::unicodeToJisx0212(uint h, uint l) const{#ifdef Q_STRICT    if ((h == 0x00) && ((l == 0x7e) || (l == 0xa6))) {        return 0x0000;    }#else    if ((h == 0x00) && (l == 0x7e)) {        return 0x0000;    }#endif    if (h == 0xff) {        if (l == 0x5e) {            return 0x2237;        } else if (l == 0xe4) {            return 0x2243;        }    }    return QJpUnicodeConv::unicodeToJisx0212(h, l);}/*! \internal */QJpUnicodeConv *QJpUnicodeConv::newConverter(int rule){    QByteArray env = qgetenv("UNICODEMAP_JP");    if (rule == Default && !env.isNull()) {        for (int i = 0; i < (int)env.length();) {            int j = env.indexOf(',', i);            QByteArray s;            if (j < 0) {                s = env.mid(i).trimmed();                i = env.length();            } else {                s = env.mid(i, j - i).trimmed();                i = j + 1;            }            if (qstricmp(s, "unicode-0.9") == 0) {                rule = (rule & 0xff00) | Unicode;            } else if (qstricmp(s, "unicode-0201") == 0) {                rule = (rule & 0xff00) | Unicode_JISX0201;            } else if (qstricmp(s, "unicode-ascii") == 0) {                rule = (rule & 0xff00) | Unicode_ASCII;            } else if (qstricmp(s, "jisx0221-1995") == 0) {                rule = (rule & 0xff00) | JISX0221_JISX0201;            } else if ((qstricmp(s, "open-0201") == 0) ||                       (qstricmp(s, "open-19970715-0201") == 0)) {                rule = (rule & 0xff00) | JISX0221_JISX0201;            } else if ((qstricmp(s, "open-ascii") == 0) ||                       (qstricmp(s, "open-19970715-ascii") == 0)) {                rule = (rule & 0xff00) | JISX0221_ASCII;            } else if ((qstricmp(s, "open-ms") == 0) ||                       (qstricmp(s, "open-19970715-ms") == 0)) {                rule = (rule & 0xff00) | Microsoft_CP932;            } else if (qstricmp(s, "cp932") == 0) {                rule = (rule & 0xff00) | Microsoft_CP932;            } else if (qstricmp(s, "jdk1.1.7") == 0) {                rule = (rule & 0xff00) | Sun_JDK117;            } else if (qstricmp(s, "nec-vdc") == 0) {                rule = rule | NEC_VDC;            } else if (qstricmp(s, "ibm-vdc") == 0) {                rule = rule | IBM_VDC;            } else if (qstricmp(s, "udc") == 0) {                rule = rule | UDC;            }        }    }    switch (rule & 0x00ff) {    case Unicode_JISX0201:        return new QJpUnicodeConv_Unicode_JISX0201(rule);    case Unicode_ASCII:        return new QJpUnicodeConv_Unicode_ASCII(rule);    case JISX0221_JISX0201:        return new QJpUnicodeConv_JISX0221_JISX0201(rule);    case JISX0221_ASCII:        return new QJpUnicodeConv_JISX0221_ASCII(rule);    case Sun_JDK117:        return new QJpUnicodeConv_Sun(rule);    case Microsoft_CP932:        return new QJpUnicodeConv_Microsoft(rule);    default:        return new QJpUnicodeConv_Unicode_ASCII(rule);    }}/* * JISX0208 <-> ShiftJIS conversion. */static uint jisx0208ToSjis(uint h, uint l){    if ((0x0021 <= h) && (h <= 0x007e) && (0x0021 <= l) && (l <= 0x007e)) {        return ((((h - 1) >> 1) + ((h <= 0x5e) ? 0x71 : 0xb1)) << 8) |               (l + ((h & 1) ? ((l < 0x60) ? 0x1f : 0x20) : 0x7e));    }    return 0x0000;}static uint sjisToJisx0208(uint h, uint l){    if ((((0x81 <= h) && (h <= 0x9f)) || ((0xe0 <= h) && (h <= 0xef))) &&        ((0x40 <= l) && (l != 0x7f) && (l <= 0xfc))) {        if (l < 0x9f) {            return (((h << 1) - ((h <= 0x9f) ? 0x00e1 : 0x0161)) << 8) |                   (l - ((l <= 0x7f) ? 0x1f : 0x20));        } else {            return (((h << 1) - ((h <= 0x9f) ? 0x00e1 : 0x0161) + 1) << 8) |                   (l - 0x7e);        }    }    return 0x0000;}/* * This function is derived from Unicode 1.1, * JIS X 0201 (1976) to Unicode mapping table version 0.9 . */#define        JISX0201_YEN_SIGN        0x005c#define        UNICODE_YEN_SIGN        0x00a5#define        JISX0201_OVERLINE        0x007e#define        UNICODE_OVERLINE        0x203estatic uint jisx0201ToUnicode11(uint h, uint l){    if (h == 0x00) {        if (l < 0x80) {            if (l == JISX0201_YEN_SIGN) {                return UNICODE_YEN_SIGN;            } else if (l == JISX0201_OVERLINE) {                return UNICODE_OVERLINE;            } else {                return l;            }        } else if ((0xa1 <= l) && (l <= 0x00df)) {            return 0xff61 + l - 0x00a1;        }    }    return 0x0000;}/* * This function is derived from Unicode 1.1, * JIS X 0201 (1976) to Unicode mapping table version 0.9 . */static uint unicode11ToJisx0201(uint h, uint l){    if ((h == 0x00) && (l < 0x80)) {        if ((l == JISX0201_YEN_SIGN) ||            (l == JISX0201_OVERLINE)) {            return 0x0000;        }        return l;    } else if ((h == 0x00) && (l == 0xa5)) {        return JISX0201_YEN_SIGN;    } else if ((h == 0x20) && (l == 0x3e)) {        return JISX0201_OVERLINE;    } else if ((h == 0xff) && (0x61 <= l) && (l <= 0x9f)) {        return 0x00a1 + l - 0x61;    }    return 0x0000;}/* * This data is derived from Unicode 1.1, * JIS X 0208 (1990) to Unicode mapping table version 0.9 . * (In addition NEC Vender Defined Char included) */static unsigned short const jisx0208_to_unicode[] = {        /* 0x2121 - 0x217e */                0x3000, 0x3001, 0x3002, 0xff0c, 0xff0e, 0x30fb, 0xff1a,        0xff1b, 0xff1f, 0xff01, 0x309b, 0x309c, 0x00b4, 0xff40, 0x00a8,        0xff3e, 0xffe3, 0xff3f, 0x30fd, 0x30fe, 0x309d, 0x309e, 0x3003,        0x4edd, 0x3005, 0x3006, 0x3007, 0x30fc, 0x2015, 0x2010, 0xff0f,        0x005c, 0x301c, 0x2016, 0xff5c, 0x2026, 0x2025, 0x2018, 0x2019,        0x201c, 0x201d, 0xff08, 0xff09, 0x3014, 0x3015, 0xff3b, 0xff3d,        0xff5b, 0xff5d, 0x3008, 0x3009, 0x300a, 0x300b, 0x300c, 0x300d,

⌨️ 快捷键说明

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