qlatincodec.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/codecs/qlatincodec.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qlatincodec_p.h"-
41#include "qlist.h"-
42-
43#ifndef QT_NO_TEXTCODEC-
44-
45QT_BEGIN_NAMESPACE-
46-
47QLatin1Codec::~QLatin1Codec()-
48{-
49}-
50-
51QString QLatin1Codec::convertToUnicode(const char *chars, int len, ConverterState *) const-
52{-
53 if (chars == 0)
chars == 0Description
TRUEnever evaluated
FALSEevaluated 122 times by 5 tests
Evaluated by:
  • tst_QSettings
  • tst_QString
  • tst_QTextBrowser
  • tst_QTextCodec
  • tst_QTextStream
0-122
54 return QString();
never executed: return QString();
0
55-
56 return QString::fromLatin1(chars, len);
executed 122 times by 5 tests: return QString::fromLatin1(chars, len);
Executed by:
  • tst_QSettings
  • tst_QString
  • tst_QTextBrowser
  • tst_QTextCodec
  • tst_QTextStream
122
57}-
58-
59-
60QByteArray QLatin1Codec::convertFromUnicode(const QChar *ch, int len, ConverterState *state) const-
61{-
62 const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?';
stateDescription
TRUEevaluated 38 times by 2 tests
Evaluated by:
  • tst_QString
  • tst_QTextStream
FALSEevaluated 63 times by 3 tests
Evaluated by:
  • tst_QSettings
  • tst_QString
  • tst_QTextCodec
38-63
63 QByteArray r(len, Qt::Uninitialized);-
64 char *d = r.data();-
65 int invalid = 0;-
66 for (int i = 0; i < len; ++i) {
i < lenDescription
TRUEevaluated 11686 times by 4 tests
Evaluated by:
  • tst_QSettings
  • tst_QString
  • tst_QTextCodec
  • tst_QTextStream
FALSEevaluated 101 times by 4 tests
Evaluated by:
  • tst_QSettings
  • tst_QString
  • tst_QTextCodec
  • tst_QTextStream
101-11686
67 if (ch[i] > 0xff) {
ch[i] > 0xffDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QString
FALSEevaluated 11678 times by 4 tests
Evaluated by:
  • tst_QSettings
  • tst_QString
  • tst_QTextCodec
  • tst_QTextStream
8-11678
68 d[i] = replacement;-
69 ++invalid;-
70 } else {
executed 8 times by 1 test: end of block
Executed by:
  • tst_QString
8
71 d[i] = (char)ch[i].cell();-
72 }
executed 11678 times by 4 tests: end of block
Executed by:
  • tst_QSettings
  • tst_QString
  • tst_QTextCodec
  • tst_QTextStream
11678
73 }-
74 if (state) {
stateDescription
TRUEevaluated 38 times by 2 tests
Evaluated by:
  • tst_QString
  • tst_QTextStream
FALSEevaluated 63 times by 3 tests
Evaluated by:
  • tst_QSettings
  • tst_QString
  • tst_QTextCodec
38-63
75 state->invalidChars += invalid;-
76 }
executed 38 times by 2 tests: end of block
Executed by:
  • tst_QString
  • tst_QTextStream
38
77 return r;
executed 101 times by 4 tests: return r;
Executed by:
  • tst_QSettings
  • tst_QString
  • tst_QTextCodec
  • tst_QTextStream
101
78}-
79-
80QByteArray QLatin1Codec::name() const-
81{-
82 return "ISO-8859-1";
executed 148 times by 7 tests: return "ISO-8859-1";
Executed by:
  • tst_QSettings
  • tst_QString
  • tst_QTextBrowser
  • tst_QTextCodec
  • tst_QTextDocument
  • tst_QTextStream
  • tst_QXmlStream
148
83}-
84-
85QList<QByteArray> QLatin1Codec::aliases() const-
86{-
87 QList<QByteArray> list;-
88 list << "latin1"-
89 << "CP819"-
90 << "IBM819"-
91 << "iso-ir-100"-
92 << "csISOLatin1";-
93 return list;
executed 142 times by 6 tests: return list;
Executed by:
  • tst_QSettings
  • tst_QString
  • tst_QTextCodec
  • tst_QTextDocument
  • tst_QTextStream
  • tst_QXmlStream
142
94}-
95-
96-
97int QLatin1Codec::mibEnum() const-
98{-
99 return 4;
executed 36 times by 2 tests: return 4;
Executed by:
  • tst_QTextCodec
  • tst_QXmlStream
36
100}-
101-
102-
103QLatin15Codec::~QLatin15Codec()-
104{-
105}-
106-
107QString QLatin15Codec::convertToUnicode(const char* chars, int len, ConverterState *) const-
108{-
109 if (chars == 0)
chars == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
110 return QString();
never executed: return QString();
0
111-
112 QString str = QString::fromLatin1(chars, len);-
113 QChar *uc = str.data();-
114 while(len--) {
len--Description
TRUEnever evaluated
FALSEnever evaluated
0
115 switch(uc->unicode()) {-
116 case 0xa4:
never executed: case 0xa4:
0
117 *uc = 0x20ac;-
118 break;
never executed: break;
0
119 case 0xa6:
never executed: case 0xa6:
0
120 *uc = 0x0160;-
121 break;
never executed: break;
0
122 case 0xa8:
never executed: case 0xa8:
0
123 *uc = 0x0161;-
124 break;
never executed: break;
0
125 case 0xb4:
never executed: case 0xb4:
0
126 *uc = 0x017d;-
127 break;
never executed: break;
0
128 case 0xb8:
never executed: case 0xb8:
0
129 *uc = 0x017e;-
130 break;
never executed: break;
0
131 case 0xbc:
never executed: case 0xbc:
0
132 *uc = 0x0152;-
133 break;
never executed: break;
0
134 case 0xbd:
never executed: case 0xbd:
0
135 *uc = 0x0153;-
136 break;
never executed: break;
0
137 case 0xbe:
never executed: case 0xbe:
0
138 *uc = 0x0178;-
139 break;
never executed: break;
0
140 default:
never executed: default:
0
141 break;
never executed: break;
0
142 }-
143 uc++;-
144 }
never executed: end of block
0
145 return str;
never executed: return str;
0
146}-
147-
148QByteArray QLatin15Codec::convertFromUnicode(const QChar *in, int length, ConverterState *state) const-
149{-
150 const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?';
stateDescription
TRUEnever evaluated
FALSEnever evaluated
state->flags &...tInvalidToNullDescription
TRUEnever evaluated
FALSEnever evaluated
0
151 QByteArray r(length, Qt::Uninitialized);-
152 char *d = r.data();-
153 int invalid = 0;-
154 for (int i = 0; i < length; ++i) {
i < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
155 uchar c;-
156 ushort uc = in[i].unicode();-
157 if (uc < 0x0100) {
uc < 0x0100Description
TRUEnever evaluated
FALSEnever evaluated
0
158 if (uc > 0xa3) {
uc > 0xa3Description
TRUEnever evaluated
FALSEnever evaluated
0
159 switch(uc) {-
160 case 0xa4:
never executed: case 0xa4:
0
161 case 0xa6:
never executed: case 0xa6:
0
162 case 0xa8:
never executed: case 0xa8:
0
163 case 0xb4:
never executed: case 0xb4:
0
164 case 0xb8:
never executed: case 0xb8:
0
165 case 0xbc:
never executed: case 0xbc:
0
166 case 0xbd:
never executed: case 0xbd:
0
167 case 0xbe:
never executed: case 0xbe:
0
168 c = replacement;-
169 ++invalid;-
170 break;
never executed: break;
0
171 default:
never executed: default:
0
172 c = (unsigned char) uc;-
173 break;
never executed: break;
0
174 }-
175 } else {-
176 c = (unsigned char) uc;-
177 }
never executed: end of block
0
178 } else {-
179 if (uc == 0x20ac)
uc == 0x20acDescription
TRUEnever evaluated
FALSEnever evaluated
0
180 c = 0xa4;
never executed: c = 0xa4;
0
181 else if ((uc & 0xff00) == 0x0100) {
(uc & 0xff00) == 0x0100Description
TRUEnever evaluated
FALSEnever evaluated
0
182 switch(uc) {-
183 case 0x0160:
never executed: case 0x0160:
0
184 c = 0xa6;-
185 break;
never executed: break;
0
186 case 0x0161:
never executed: case 0x0161:
0
187 c = 0xa8;-
188 break;
never executed: break;
0
189 case 0x017d:
never executed: case 0x017d:
0
190 c = 0xb4;-
191 break;
never executed: break;
0
192 case 0x017e:
never executed: case 0x017e:
0
193 c = 0xb8;-
194 break;
never executed: break;
0
195 case 0x0152:
never executed: case 0x0152:
0
196 c = 0xbc;-
197 break;
never executed: break;
0
198 case 0x0153:
never executed: case 0x0153:
0
199 c = 0xbd;-
200 break;
never executed: break;
0
201 case 0x0178:
never executed: case 0x0178:
0
202 c = 0xbe;-
203 break;
never executed: break;
0
204 default:
never executed: default:
0
205 c = replacement;-
206 ++invalid;-
207 }
never executed: end of block
0
208 } else {-
209 c = replacement;-
210 ++invalid;-
211 }
never executed: end of block
0
212 }-
213 d[i] = (char)c;-
214 }
never executed: end of block
0
215 if (state) {
stateDescription
TRUEnever evaluated
FALSEnever evaluated
0
216 state->remainingChars = 0;-
217 state->invalidChars += invalid;-
218 }
never executed: end of block
0
219 return r;
never executed: return r;
0
220}-
221-
222-
223QByteArray QLatin15Codec::name() const-
224{-
225 return "ISO-8859-15";
never executed: return "ISO-8859-15";
0
226}-
227-
228QList<QByteArray> QLatin15Codec::aliases() const-
229{-
230 QList<QByteArray> list;-
231 list << "latin9";-
232 return list;
never executed: return list;
0
233}-
234-
235int QLatin15Codec::mibEnum() const-
236{-
237 return 111;
never executed: return 111;
0
238}-
239-
240QT_END_NAMESPACE-
241-
242#endif // QT_NO_TEXTCODEC-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9