~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/plugins/codecs/jp/qjpunicode.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the internationalization module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
// Most of the code here was originally written by Serika Kurusugawa
 
30
// a.k.a. Junji Takagi, and is included in Qt with the author's permission,
 
31
// and the grateful thanks of the Trolltech team.
 
32
 
 
33
/*
 
34
 * Copyright (C) 1999 Serika Kurusugawa, All rights reserved.
 
35
 *
 
36
 * Redistribution and use in source and binary forms, with or without
 
37
 * modification, are permitted provided that the following conditions
 
38
 * are met:
 
39
 * 1. Redistributions of source code must retain the above copyright
 
40
 *    notice, this list of conditions and the following disclaimer.
 
41
 * 2. Redistributions in binary form must reproduce the above copyright
 
42
 *    notice, this list of conditions and the following disclaimer in the
 
43
 *    documentation and/or other materials provided with the distribution.
 
44
 *
 
45
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 
46
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
47
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
48
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 
49
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
50
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
51
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
52
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
53
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
54
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
55
 * SUCH DAMAGE.
 
56
 */
 
57
 
 
58
#ifndef QJPUNICODE_H
 
59
#define QJPUNICODE_H
 
60
 
 
61
#include "qglobal.h"
 
62
 
 
63
class QJpUnicodeConv {
 
64
public:
 
65
    virtual ~QJpUnicodeConv() {}
 
66
    enum Rules {
 
67
        // "ASCII" is ANSI X.3.4-1986, a.k.a. US-ASCII here.
 
68
        Default                        = 0x0000,
 
69
 
 
70
        Unicode                        = 0x0001,
 
71
        Unicode_JISX0201                = 0x0001,
 
72
        Unicode_ASCII                 = 0x0002,
 
73
        JISX0221_JISX0201         = 0x0003,
 
74
        JISX0221_ASCII                = 0x0004,
 
75
        Sun_JDK117                     = 0x0005,
 
76
        Microsoft_CP932                = 0x0006,
 
77
 
 
78
        NEC_VDC                = 0x0100,                // NEC Vender Defined Char
 
79
        UDC                        = 0x0200,                // User Defined Char
 
80
        IBM_VDC                = 0x0400                // IBM Vender Defined Char
 
81
    };
 
82
    static QJpUnicodeConv *newConverter(int rule);
 
83
 
 
84
    virtual uint asciiToUnicode(uint h, uint l) const;
 
85
    /*virtual*/ uint jisx0201ToUnicode(uint h, uint l) const;
 
86
    virtual uint jisx0201LatinToUnicode(uint h, uint l) const;
 
87
    /*virtual*/ uint jisx0201KanaToUnicode(uint h, uint l) const;
 
88
    virtual uint jisx0208ToUnicode(uint h, uint l) const;
 
89
    virtual uint jisx0212ToUnicode(uint h, uint l) const;
 
90
 
 
91
    uint asciiToUnicode(uint ascii) const {
 
92
        return asciiToUnicode((ascii & 0xff00) >> 8, (ascii & 0x00ff));
 
93
    }
 
94
    uint jisx0201ToUnicode(uint jis) const {
 
95
        return jisx0201ToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
 
96
    }
 
97
    uint jisx0201LatinToUnicode(uint jis) const {
 
98
        return jisx0201LatinToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
 
99
    }
 
100
    uint jisx0201KanaToUnicode(uint jis) const {
 
101
        return jisx0201KanaToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
 
102
    }
 
103
    uint jisx0208ToUnicode(uint jis) const {
 
104
        return jisx0208ToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
 
105
    }
 
106
    uint jisx0212ToUnicode(uint jis) const {
 
107
        return jisx0212ToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
 
108
    }
 
109
 
 
110
    virtual uint unicodeToAscii(uint h, uint l) const;
 
111
    /*virtual*/ uint unicodeToJisx0201(uint h, uint l) const;
 
112
    virtual uint unicodeToJisx0201Latin(uint h, uint l) const;
 
113
    /*virtual*/ uint unicodeToJisx0201Kana(uint h, uint l) const;
 
114
    virtual uint unicodeToJisx0208(uint h, uint l) const;
 
115
    virtual uint unicodeToJisx0212(uint h, uint l) const;
 
116
 
 
117
    uint unicodeToAscii(uint unicode) const {
 
118
        return unicodeToAscii((unicode & 0xff00) >> 8, (unicode & 0x00ff));
 
119
    }
 
120
    uint unicodeToJisx0201(uint unicode) const {
 
121
        return unicodeToJisx0201((unicode & 0xff00) >> 8, (unicode & 0x00ff));
 
122
    }
 
123
    uint unicodeToJisx0201Latin(uint unicode) const {
 
124
        return unicodeToJisx0201Latin((unicode & 0xff00) >> 8, (unicode & 0x00ff));
 
125
    }
 
126
    uint unicodeToJisx0201Kana(uint unicode) const {
 
127
        return unicodeToJisx0201Kana((unicode & 0xff00) >> 8, (unicode & 0x00ff));
 
128
    }
 
129
    uint unicodeToJisx0208(uint unicode) const {
 
130
        return unicodeToJisx0208((unicode & 0xff00) >> 8, (unicode & 0x00ff));
 
131
    }
 
132
    uint unicodeToJisx0212(uint unicode) const {
 
133
        return unicodeToJisx0212((unicode & 0xff00) >> 8, (unicode & 0x00ff));
 
134
    }
 
135
 
 
136
    uint sjisToUnicode(uint h, uint l) const;
 
137
    uint unicodeToSjis(uint h, uint l) const;
 
138
 
 
139
    uint sjisToUnicode(uint sjis) const {
 
140
        return sjisToUnicode((sjis & 0xff00) >> 8, (sjis & 0x00ff));
 
141
    }
 
142
    uint unicodeToSjis(uint unicode) const {
 
143
        return unicodeToSjis((unicode & 0xff00) >> 8, (unicode & 0x00ff));
 
144
    }
 
145
 
 
146
protected:
 
147
    explicit QJpUnicodeConv(int r) : rule(r) {}
 
148
 
 
149
private:
 
150
    int rule;
 
151
};
 
152
 
 
153
#endif // QJPUNICODE_H