Qt 4.8
qfontjpcodec.cpp
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 #include "qfontjpcodec.h"
43 
44 #include "qjpunicode.h"
45 
47 
48 #ifdef Q_WS_X11
49 // JIS X 0201
50 
52 {
53 }
54 
56 {
57  return "jisx0201*-0";
58 }
59 
61 {
62  return 15;
63 }
64 
66 {
67  QByteArray rstring;
68  rstring.resize(len);
69  uchar *rdata = (uchar *) rstring.data();
70  const QChar *sdata = uc;
71  int i = 0;
72  for (; i < len; ++i, ++sdata, ++rdata) {
73  if (sdata->unicode() < 0x80) {
74  *rdata = (uchar) sdata->unicode();
75  } else if (sdata->unicode() >= 0xff61 && sdata->unicode() <= 0xff9f) {
76  *rdata = (uchar) (sdata->unicode() - 0xff61 + 0xa1);
77  } else {
78  *rdata = 0;
79  }
80  }
81  return rstring;
82 }
83 
85 {
86  return QString();
87 }
88 
89 // JIS X 0208
90 
92 {
94 }
95 
96 
98 {
99  delete convJP;
100  convJP = 0;
101 }
102 
103 
105 {
106  return "jisx0208*-0";
107 }
108 
109 
111 {
112  return 63;
113 }
114 
115 
116 QString QFontJis0208Codec::convertToUnicode(const char* /*chars*/, int /*len*/, ConverterState *) const
117 {
118  return QString();
119 }
120 
122 {
123  QByteArray result;
124  result.resize(len * 2);
125  uchar *rdata = (uchar *) result.data();
126  const QChar *ucp = uc;
127 
128  for (int i = 0; i < len; i++) {
129  QChar ch(*ucp++);
130  ch = convJP->unicodeToJisx0208(ch.unicode());
131 
132  if (!ch.isNull()) {
133  *rdata++ = ch.row();
134  *rdata++ = ch.cell();
135  } else {
136  *rdata++ = 0;
137  *rdata++ = 0;
138  }
139  }
140  return result;
141 }
142 
143 #endif
144 
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
bool isNull() const
Returns true if the character is the Unicode character 0x0000 (&#39;\0&#39;); otherwise returns false...
Definition: qchar.h:262
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QString convertToUnicode(const char *, int, ConverterState *) const
QTextCodec subclasses must reimplement this function.
static QByteArray _name()
unsigned char uchar
Definition: qglobal.h:994
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static QByteArray _name()
QString convertToUnicode(const char *, int, ConverterState *) const
QTextCodec subclasses must reimplement this function.
QByteArray convertFromUnicode(const QChar *uc, int len, ConverterState *) const
QTextCodec subclasses must reimplement this function.
static int _mibEnum()
void resize(int size)
Sets the size of the byte array to size bytes.
uchar cell() const
Returns the cell (least significant byte) of the Unicode character.
Definition: qchar.h:283
static QJpUnicodeConv * newConverter(int rule)
Definition: qjpunicode.cpp:727
static int _mibEnum()
uchar row() const
Returns the row (most significant byte) of the Unicode character.
Definition: qchar.h:284
QByteArray convertFromUnicode(const QChar *uc, int len, ConverterState *) const
QTextCodec subclasses must reimplement this function.