codecs/qlatincodec.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module 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 "qlatincodec_p.h" -
43#include "qlist.h" -
44 -
45#ifndef QT_NO_TEXTCODEC -
46 -
47QT_BEGIN_NAMESPACE -
48 -
49QLatin1Codec::~QLatin1Codec() -
50{ -
51} -
52 -
53QString QLatin1Codec::convertToUnicode(const char *chars, int len, ConverterState *) const -
54{ -
55 if (chars == 0)
partially evaluated: chars == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
56 return QString();
never executed: return QString();
0
57 -
58 return QString::fromLatin1(chars, len);
executed: return QString::fromLatin1(chars, len);
Execution Count:107
107
59} -
60 -
61 -
62QByteArray QLatin1Codec::convertFromUnicode(const QChar *ch, int len, ConverterState *state) const -
63{ -
64 const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?';
evaluated: state
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:40
partially evaluated: state->flags & ConvertInvalidToNull
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37
0-40
65 QByteArray r(len, Qt::Uninitialized);
executed (the execution status of this line is deduced): QByteArray r(len, Qt::Uninitialized);
-
66 char *d = r.data();
executed (the execution status of this line is deduced): char *d = r.data();
-
67 int invalid = 0;
executed (the execution status of this line is deduced): int invalid = 0;
-
68 for (int i = 0; i < len; ++i) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:10439
yes
Evaluation Count:77
77-10439
69 if (ch[i] > 0xff) {
partially evaluated: ch[i] > 0xff
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10439
0-10439
70 d[i] = replacement;
never executed (the execution status of this line is deduced): d[i] = replacement;
-
71 ++invalid;
never executed (the execution status of this line is deduced): ++invalid;
-
72 } else {
never executed: }
0
73 d[i] = (char)ch[i].cell();
executed (the execution status of this line is deduced): d[i] = (char)ch[i].cell();
-
74 }
executed: }
Execution Count:10439
10439
75 } -
76 if (state) {
evaluated: state
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:40
37-40
77 state->invalidChars += invalid;
executed (the execution status of this line is deduced): state->invalidChars += invalid;
-
78 }
executed: }
Execution Count:37
37
79 return r;
executed: return r;
Execution Count:77
77
80} -
81 -
82QByteArray QLatin1Codec::name() const -
83{ -
84 return "ISO-8859-1";
executed: return "ISO-8859-1";
Execution Count:133
133
85} -
86 -
87QList<QByteArray> QLatin1Codec::aliases() const -
88{ -
89 QList<QByteArray> list;
executed (the execution status of this line is deduced): QList<QByteArray> list;
-
90 list << "latin1"
executed (the execution status of this line is deduced): list << "latin1"
-
91 << "CP819"
executed (the execution status of this line is deduced): << "CP819"
-
92 << "IBM819"
executed (the execution status of this line is deduced): << "IBM819"
-
93 << "iso-ir-100"
executed (the execution status of this line is deduced): << "iso-ir-100"
-
94 << "csISOLatin1";
executed (the execution status of this line is deduced): << "csISOLatin1";
-
95 return list;
executed: return list;
Execution Count:128
128
96} -
97 -
98 -
99int QLatin1Codec::mibEnum() const -
100{ -
101 return 4;
executed: return 4;
Execution Count:29
29
102} -
103 -
104 -
105QLatin15Codec::~QLatin15Codec() -
106{ -
107} -
108 -
109QString QLatin15Codec::convertToUnicode(const char* chars, int len, ConverterState *) const -
110{ -
111 if (chars == 0)
never evaluated: chars == 0
0
112 return QString();
never executed: return QString();
0
113 -
114 QString str = QString::fromLatin1(chars, len);
never executed (the execution status of this line is deduced): QString str = QString::fromLatin1(chars, len);
-
115 QChar *uc = str.data();
never executed (the execution status of this line is deduced): QChar *uc = str.data();
-
116 while(len--) {
never evaluated: len--
0
117 switch(uc->unicode()) { -
118 case 0xa4: -
119 *uc = 0x20ac;
never executed (the execution status of this line is deduced): *uc = 0x20ac;
-
120 break;
never executed: break;
0
121 case 0xa6: -
122 *uc = 0x0160;
never executed (the execution status of this line is deduced): *uc = 0x0160;
-
123 break;
never executed: break;
0
124 case 0xa8: -
125 *uc = 0x0161;
never executed (the execution status of this line is deduced): *uc = 0x0161;
-
126 break;
never executed: break;
0
127 case 0xb4: -
128 *uc = 0x017d;
never executed (the execution status of this line is deduced): *uc = 0x017d;
-
129 break;
never executed: break;
0
130 case 0xb8: -
131 *uc = 0x017e;
never executed (the execution status of this line is deduced): *uc = 0x017e;
-
132 break;
never executed: break;
0
133 case 0xbc: -
134 *uc = 0x0152;
never executed (the execution status of this line is deduced): *uc = 0x0152;
-
135 break;
never executed: break;
0
136 case 0xbd: -
137 *uc = 0x0153;
never executed (the execution status of this line is deduced): *uc = 0x0153;
-
138 break;
never executed: break;
0
139 case 0xbe: -
140 *uc = 0x0178;
never executed (the execution status of this line is deduced): *uc = 0x0178;
-
141 break;
never executed: break;
0
142 default: -
143 break;
never executed: break;
0
144 } -
145 uc++;
never executed (the execution status of this line is deduced): uc++;
-
146 }
never executed: }
0
147 return str;
never executed: return str;
0
148} -
149 -
150QByteArray QLatin15Codec::convertFromUnicode(const QChar *in, int length, ConverterState *state) const -
151{ -
152 const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?';
never evaluated: state
never evaluated: state->flags & ConvertInvalidToNull
0
153 QByteArray r(length, Qt::Uninitialized);
never executed (the execution status of this line is deduced): QByteArray r(length, Qt::Uninitialized);
-
154 char *d = r.data();
never executed (the execution status of this line is deduced): char *d = r.data();
-
155 int invalid = 0;
never executed (the execution status of this line is deduced): int invalid = 0;
-
156 for (int i = 0; i < length; ++i) {
never evaluated: i < length
0
157 uchar c;
never executed (the execution status of this line is deduced): uchar c;
-
158 ushort uc = in[i].unicode();
never executed (the execution status of this line is deduced): ushort uc = in[i].unicode();
-
159 if (uc < 0x0100) {
never evaluated: uc < 0x0100
0
160 if (uc > 0xa3) {
never evaluated: uc > 0xa3
0
161 switch(uc) { -
162 case 0xa4: -
163 case 0xa6: -
164 case 0xa8: -
165 case 0xb4: -
166 case 0xb8: -
167 case 0xbc: -
168 case 0xbd: -
169 case 0xbe: -
170 c = replacement;
never executed (the execution status of this line is deduced): c = replacement;
-
171 ++invalid;
never executed (the execution status of this line is deduced): ++invalid;
-
172 break;
never executed: break;
0
173 default: -
174 c = (unsigned char) uc;
never executed (the execution status of this line is deduced): c = (unsigned char) uc;
-
175 break;
never executed: break;
0
176 } -
177 } else {
never executed: }
0
178 c = (unsigned char) uc;
never executed (the execution status of this line is deduced): c = (unsigned char) uc;
-
179 }
never executed: }
0
180 } else { -
181 if (uc == 0x20ac)
never evaluated: uc == 0x20ac
0
182 c = 0xa4;
never executed: c = 0xa4;
0
183 else if ((uc & 0xff00) == 0x0100) {
never evaluated: (uc & 0xff00) == 0x0100
0
184 switch(uc) { -
185 case 0x0160: -
186 c = 0xa6;
never executed (the execution status of this line is deduced): c = 0xa6;
-
187 break;
never executed: break;
0
188 case 0x0161: -
189 c = 0xa8;
never executed (the execution status of this line is deduced): c = 0xa8;
-
190 break;
never executed: break;
0
191 case 0x017d: -
192 c = 0xb4;
never executed (the execution status of this line is deduced): c = 0xb4;
-
193 break;
never executed: break;
0
194 case 0x017e: -
195 c = 0xb8;
never executed (the execution status of this line is deduced): c = 0xb8;
-
196 break;
never executed: break;
0
197 case 0x0152: -
198 c = 0xbc;
never executed (the execution status of this line is deduced): c = 0xbc;
-
199 break;
never executed: break;
0
200 case 0x0153: -
201 c = 0xbd;
never executed (the execution status of this line is deduced): c = 0xbd;
-
202 break;
never executed: break;
0
203 case 0x0178: -
204 c = 0xbe;
never executed (the execution status of this line is deduced): c = 0xbe;
-
205 break;
never executed: break;
0
206 default: -
207 c = replacement;
never executed (the execution status of this line is deduced): c = replacement;
-
208 ++invalid;
never executed (the execution status of this line is deduced): ++invalid;
-
209 }
never executed: }
0
210 } else {
never executed: }
0
211 c = replacement;
never executed (the execution status of this line is deduced): c = replacement;
-
212 ++invalid;
never executed (the execution status of this line is deduced): ++invalid;
-
213 }
never executed: }
0
214 } -
215 d[i] = (char)c;
never executed (the execution status of this line is deduced): d[i] = (char)c;
-
216 }
never executed: }
0
217 if (state) {
never evaluated: state
0
218 state->remainingChars = 0;
never executed (the execution status of this line is deduced): state->remainingChars = 0;
-
219 state->invalidChars += invalid;
never executed (the execution status of this line is deduced): state->invalidChars += invalid;
-
220 }
never executed: }
0
221 return r;
never executed: return r;
0
222} -
223 -
224 -
225QByteArray QLatin15Codec::name() const -
226{ -
227 return "ISO-8859-15";
never executed: return "ISO-8859-15";
0
228} -
229 -
230QList<QByteArray> QLatin15Codec::aliases() const -
231{ -
232 QList<QByteArray> list;
never executed (the execution status of this line is deduced): QList<QByteArray> list;
-
233 list << "latin9";
never executed (the execution status of this line is deduced): list << "latin9";
-
234 return list;
never executed: return list;
0
235} -
236 -
237int QLatin15Codec::mibEnum() const -
238{ -
239 return 111;
never executed: return 111;
0
240} -
241 -
242QT_END_NAMESPACE -
243 -
244#endif // QT_NO_TEXTCODEC -
245 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial