Qt 4.8
qjpunicode.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 // Most of the code here was originally written by Serika Kurusugawa
43 // a.k.a. Junji Takagi, and is included in Qt with the author's permission,
44 // and the grateful thanks of the Qt team.
45 
46 /*
47  * Copyright (C) 1999 Serika Kurusugawa, All rights reserved.
48  *
49  * Redistribution and use in source and binary forms, with or without
50  * modification, are permitted provided that the following conditions
51  * are met:
52  * 1. Redistributions of source code must retain the above copyright
53  * notice, this list of conditions and the following disclaimer.
54  * 2. Redistributions in binary form must reproduce the above copyright
55  * notice, this list of conditions and the following disclaimer in the
56  * documentation and/or other materials provided with the distribution.
57  *
58  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
59  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68  * SUCH DAMAGE.
69  */
70 
71 #ifndef QJPUNICODE_H
72 #define QJPUNICODE_H
73 
74 #include <QtCore/qglobal.h>
75 
77 
79 public:
80  virtual ~QJpUnicodeConv() {}
81  enum Rules {
82  // "ASCII" is ANSI X.3.4-1986, a.k.a. US-ASCII here.
83  Default = 0x0000,
84 
85  Unicode = 0x0001,
86  Unicode_JISX0201 = 0x0001,
87  Unicode_ASCII = 0x0002,
89  JISX0221_ASCII = 0x0004,
90  Sun_JDK117 = 0x0005,
91  Microsoft_CP932 = 0x0006,
92 
93  NEC_VDC = 0x0100, // NEC Vender Defined Char
94  UDC = 0x0200, // User Defined Char
95  IBM_VDC = 0x0400 // IBM Vender Defined Char
96  };
97  static QJpUnicodeConv *newConverter(int rule);
98 
99  virtual uint asciiToUnicode(uint h, uint l) const;
100  /*virtual*/ uint jisx0201ToUnicode(uint h, uint l) const;
101  virtual uint jisx0201LatinToUnicode(uint h, uint l) const;
102  /*virtual*/ uint jisx0201KanaToUnicode(uint h, uint l) const;
103  virtual uint jisx0208ToUnicode(uint h, uint l) const;
104  virtual uint jisx0212ToUnicode(uint h, uint l) const;
105 
106  uint asciiToUnicode(uint ascii) const {
107  return asciiToUnicode((ascii & 0xff00) >> 8, (ascii & 0x00ff));
108  }
110  return jisx0201ToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
111  }
113  return jisx0201LatinToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
114  }
116  return jisx0201KanaToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
117  }
119  return jisx0208ToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
120  }
122  return jisx0212ToUnicode((jis & 0xff00) >> 8, (jis & 0x00ff));
123  }
124 
125  virtual uint unicodeToAscii(uint h, uint l) const;
126  /*virtual*/ uint unicodeToJisx0201(uint h, uint l) const;
127  virtual uint unicodeToJisx0201Latin(uint h, uint l) const;
128  /*virtual*/ uint unicodeToJisx0201Kana(uint h, uint l) const;
129  virtual uint unicodeToJisx0208(uint h, uint l) const;
130  virtual uint unicodeToJisx0212(uint h, uint l) const;
131 
132  uint unicodeToAscii(uint unicode) const {
133  return unicodeToAscii((unicode & 0xff00) >> 8, (unicode & 0x00ff));
134  }
135  uint unicodeToJisx0201(uint unicode) const {
136  return unicodeToJisx0201((unicode & 0xff00) >> 8, (unicode & 0x00ff));
137  }
139  return unicodeToJisx0201Latin((unicode & 0xff00) >> 8, (unicode & 0x00ff));
140  }
141  uint unicodeToJisx0201Kana(uint unicode) const {
142  return unicodeToJisx0201Kana((unicode & 0xff00) >> 8, (unicode & 0x00ff));
143  }
144  uint unicodeToJisx0208(uint unicode) const {
145  return unicodeToJisx0208((unicode & 0xff00) >> 8, (unicode & 0x00ff));
146  }
147  uint unicodeToJisx0212(uint unicode) const {
148  return unicodeToJisx0212((unicode & 0xff00) >> 8, (unicode & 0x00ff));
149  }
150 
151  uint sjisToUnicode(uint h, uint l) const;
152  uint unicodeToSjis(uint h, uint l) const;
153  uint sjisibmvdcToUnicode(uint h, uint l) const;
154  uint unicodeToSjisibmvdc(uint h, uint l) const;
155  uint cp932ToUnicode(uint h, uint l) const;
156  uint unicodeToCp932(uint h, uint l) const;
157 
158  uint sjisToUnicode(uint sjis) const {
159  return sjisToUnicode((sjis & 0xff00) >> 8, (sjis & 0x00ff));
160  }
161  uint unicodeToSjis(uint unicode) const {
162  return unicodeToSjis((unicode & 0xff00) >> 8, (unicode & 0x00ff));
163  }
164 
165 protected:
166  explicit QJpUnicodeConv(int r) : rule(r) {}
167 
168 private:
169  int rule;
170 };
171 
173 
174 #endif // QJPUNICODE_H
uint unicodeToSjis(uint h, uint l) const
Definition: qjpunicode.cpp:275
virtual uint unicodeToJisx0212(uint h, uint l) const
Definition: qjpunicode.cpp:242
uint unicodeToJisx0201Kana(uint unicode) const
Definition: qjpunicode.h:141
uint jisx0201ToUnicode(uint jis) const
Definition: qjpunicode.h:109
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
uint unicodeToJisx0201(uint h, uint l) const
Definition: qjpunicode.cpp:189
virtual uint jisx0208ToUnicode(uint h, uint l) const
Definition: qjpunicode.cpp:143
uint jisx0208ToUnicode(uint jis) const
Definition: qjpunicode.h:118
uint unicodeToJisx0201(uint unicode) const
Definition: qjpunicode.h:135
virtual uint asciiToUnicode(uint h, uint l) const
Definition: qjpunicode.cpp:103
uint unicodeToSjisibmvdc(uint h, uint l) const
uint jisx0201KanaToUnicode(uint h, uint l) const
Definition: qjpunicode.cpp:134
uint unicodeToJisx0201Kana(uint h, uint l) const
Definition: qjpunicode.cpp:211
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
uint jisx0201KanaToUnicode(uint jis) const
Definition: qjpunicode.h:115
uint unicodeToAscii(uint unicode) const
Definition: qjpunicode.h:132
uint jisx0212ToUnicode(uint jis) const
Definition: qjpunicode.h:121
uint unicodeToSjis(uint unicode) const
Definition: qjpunicode.h:161
unsigned int uint
Definition: qglobal.h:996
uint jisx0201ToUnicode(uint h, uint l) const
Definition: qjpunicode.cpp:112
uint sjisibmvdcToUnicode(uint h, uint l) const
uint unicodeToJisx0201Latin(uint unicode) const
Definition: qjpunicode.h:138
uint jisx0201LatinToUnicode(uint jis) const
Definition: qjpunicode.h:112
uint asciiToUnicode(uint ascii) const
Definition: qjpunicode.h:106
virtual uint jisx0212ToUnicode(uint h, uint l) const
Definition: qjpunicode.cpp:161
uint unicodeToJisx0212(uint unicode) const
Definition: qjpunicode.h:147
virtual uint jisx0201LatinToUnicode(uint h, uint l) const
Definition: qjpunicode.cpp:125
virtual ~QJpUnicodeConv()
Definition: qjpunicode.h:80
uint cp932ToUnicode(uint h, uint l) const
QJpUnicodeConv(int r)
Definition: qjpunicode.h:166
virtual uint unicodeToJisx0208(uint h, uint l) const
Definition: qjpunicode.cpp:221
uint unicodeToJisx0208(uint unicode) const
Definition: qjpunicode.h:144
QFactoryLoader * l
static QJpUnicodeConv * newConverter(int rule)
Definition: qjpunicode.cpp:727
uint sjisToUnicode(uint h, uint l) const
Definition: qjpunicode.cpp:264
uint sjisToUnicode(uint sjis) const
Definition: qjpunicode.h:158
uint unicodeToCp932(uint h, uint l) const
virtual uint unicodeToAscii(uint h, uint l) const
Definition: qjpunicode.cpp:180
virtual uint unicodeToJisx0201Latin(uint h, uint l) const
Definition: qjpunicode.cpp:201