|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the plugins of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "qfontjpcodec.h" |
|
43 |
|
44 #include "qjpunicode.h" |
|
45 |
|
46 QT_BEGIN_NAMESPACE |
|
47 |
|
48 #ifdef Q_WS_X11 |
|
49 // JIS X 0201 |
|
50 |
|
51 QFontJis0201Codec::QFontJis0201Codec() |
|
52 { |
|
53 } |
|
54 |
|
55 QByteArray QFontJis0201Codec::_name() |
|
56 { |
|
57 return "jisx0201*-0"; |
|
58 } |
|
59 |
|
60 int QFontJis0201Codec::_mibEnum() |
|
61 { |
|
62 return 15; |
|
63 } |
|
64 |
|
65 QByteArray QFontJis0201Codec::convertFromUnicode(const QChar *uc, int len, ConverterState *) const |
|
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 |
|
84 QString QFontJis0201Codec::convertToUnicode(const char *, int, ConverterState *) const |
|
85 { |
|
86 return QString(); |
|
87 } |
|
88 |
|
89 // JIS X 0208 |
|
90 |
|
91 QFontJis0208Codec::QFontJis0208Codec() |
|
92 { |
|
93 convJP = QJpUnicodeConv::newConverter(QJpUnicodeConv::Default); |
|
94 } |
|
95 |
|
96 |
|
97 QFontJis0208Codec::~QFontJis0208Codec() |
|
98 { |
|
99 delete convJP; |
|
100 convJP = 0; |
|
101 } |
|
102 |
|
103 |
|
104 QByteArray QFontJis0208Codec::_name() |
|
105 { |
|
106 return "jisx0208*-0"; |
|
107 } |
|
108 |
|
109 |
|
110 int QFontJis0208Codec::_mibEnum() |
|
111 { |
|
112 return 63; |
|
113 } |
|
114 |
|
115 |
|
116 QString QFontJis0208Codec::convertToUnicode(const char* /*chars*/, int /*len*/, ConverterState *) const |
|
117 { |
|
118 return QString(); |
|
119 } |
|
120 |
|
121 QByteArray QFontJis0208Codec::convertFromUnicode(const QChar *uc, int len, ConverterState *) const |
|
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 |
|
145 QT_END_NAMESPACE |