1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the internationalization module of the Qt Toolkit.
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.
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.
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.
21
** Contact info@trolltech.com if any conditions of this licensing are
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.
27
****************************************************************************/
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.
34
* Copyright (C) 1999 Serika Kurusugawa, All rights reserved.
36
* Redistribution and use in source and binary forms, with or without
37
* modification, are permitted provided that the following conditions
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.
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
63
class QJpUnicodeConv {
65
virtual ~QJpUnicodeConv() {}
67
// "ASCII" is ANSI X.3.4-1986, a.k.a. US-ASCII here.
71
Unicode_JISX0201 = 0x0001,
72
Unicode_ASCII = 0x0002,
73
JISX0221_JISX0201 = 0x0003,
74
JISX0221_ASCII = 0x0004,
76
Microsoft_CP932 = 0x0006,
78
NEC_VDC = 0x0100, // NEC Vender Defined Char
79
UDC = 0x0200, // User Defined Char
80
IBM_VDC = 0x0400 // IBM Vender Defined Char
82
static QJpUnicodeConv *newConverter(int rule);
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;
91
uint asciiToUnicode(uint ascii) const {
92
return asciiToUnicode((ascii & 0xff00) >> 8, (ascii & 0x00ff));
94
uint jisx0201ToUnicode(uint jis) const {
95
return jisx0201ToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
97
uint jisx0201LatinToUnicode(uint jis) const {
98
return jisx0201LatinToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
100
uint jisx0201KanaToUnicode(uint jis) const {
101
return jisx0201KanaToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
103
uint jisx0208ToUnicode(uint jis) const {
104
return jisx0208ToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
106
uint jisx0212ToUnicode(uint jis) const {
107
return jisx0212ToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
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;
117
uint unicodeToAscii(uint unicode) const {
118
return unicodeToAscii((unicode & 0xff00) >> 8, (unicode & 0x00ff));
120
uint unicodeToJisx0201(uint unicode) const {
121
return unicodeToJisx0201((unicode & 0xff00) >> 8, (unicode & 0x00ff));
123
uint unicodeToJisx0201Latin(uint unicode) const {
124
return unicodeToJisx0201Latin((unicode & 0xff00) >> 8, (unicode & 0x00ff));
126
uint unicodeToJisx0201Kana(uint unicode) const {
127
return unicodeToJisx0201Kana((unicode & 0xff00) >> 8, (unicode & 0x00ff));
129
uint unicodeToJisx0208(uint unicode) const {
130
return unicodeToJisx0208((unicode & 0xff00) >> 8, (unicode & 0x00ff));
132
uint unicodeToJisx0212(uint unicode) const {
133
return unicodeToJisx0212((unicode & 0xff00) >> 8, (unicode & 0x00ff));
136
uint sjisToUnicode(uint h, uint l) const;
137
uint unicodeToSjis(uint h, uint l) const;
139
uint sjisToUnicode(uint sjis) const {
140
return sjisToUnicode((sjis & 0xff00) >> 8, (sjis & 0x00ff));
142
uint unicodeToSjis(uint unicode) const {
143
return unicodeToSjis((unicode & 0xff00) >> 8, (unicode & 0x00ff));
147
explicit QJpUnicodeConv(int r) : rule(r) {}
153
#endif // QJPUNICODE_H