Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/codecs/qicucodec.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
5 | ** | - | ||||||||||||||||||
6 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||||||||
7 | ** | - | ||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
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 http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
15 | ** information use the contact form at http://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 2.1 or version 3 as published by the Free | - | ||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
25 | ** | - | ||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
29 | ** | - | ||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
31 | ** | - | ||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | #include "qicucodec_p.h" | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | #ifndef QT_NO_TEXTCODEC | - | ||||||||||||||||||
37 | - | |||||||||||||||||||
38 | #include "qtextcodec_p.h" | - | ||||||||||||||||||
39 | #include "qutfcodec_p.h" | - | ||||||||||||||||||
40 | #include "qlatincodec_p.h" | - | ||||||||||||||||||
41 | #include "qtsciicodec_p.h" | - | ||||||||||||||||||
42 | #include "qisciicodec_p.h" | - | ||||||||||||||||||
43 | #include "qsimplecodec_p.h" | - | ||||||||||||||||||
44 | #include "private/qcoreglobaldata_p.h" | - | ||||||||||||||||||
45 | #include "qdebug.h" | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | #include "unicode/ucnv.h" | - | ||||||||||||||||||
48 | - | |||||||||||||||||||
49 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
50 | - | |||||||||||||||||||
51 | typedef QList<QTextCodec*>::ConstIterator TextCodecListConstIt; | - | ||||||||||||||||||
52 | typedef QList<QByteArray>::ConstIterator ByteArrayListConstIt; | - | ||||||||||||||||||
53 | - | |||||||||||||||||||
54 | static void qIcuCodecStateFree(QTextCodec::ConverterState *state) | - | ||||||||||||||||||
55 | { | - | ||||||||||||||||||
56 | ucnv_close(static_cast<UConverter *>(state->d)); | - | ||||||||||||||||||
57 | } executed 14 times by 3 tests: end of block Executed by:
| 14 | ||||||||||||||||||
58 | - | |||||||||||||||||||
59 | bool qTextCodecNameMatch(const char *n, const char *h) | - | ||||||||||||||||||
60 | { | - | ||||||||||||||||||
61 | return ucnv_compareNames(n, h) == 0; executed 487705 times by 18 tests: return ucnv_compareNames_52(n, h) == 0; Executed by:
| 487705 | ||||||||||||||||||
62 | } | - | ||||||||||||||||||
63 | - | |||||||||||||||||||
64 | /* The list below is generated from http://www.iana.org/assignments/character-sets/ | - | ||||||||||||||||||
65 | using the snippet of code below: | - | ||||||||||||||||||
66 | - | |||||||||||||||||||
67 | #include <QtCore> | - | ||||||||||||||||||
68 | #include <unicode/ucnv.h> | - | ||||||||||||||||||
69 | - | |||||||||||||||||||
70 | int main(int argc, char **argv) | - | ||||||||||||||||||
71 | { | - | ||||||||||||||||||
72 | QCoreApplication app(argc, argv); | - | ||||||||||||||||||
73 | - | |||||||||||||||||||
74 | QFile file("character-sets.txt"); | - | ||||||||||||||||||
75 | file.open(QFile::ReadOnly); | - | ||||||||||||||||||
76 | QByteArray name; | - | ||||||||||||||||||
77 | int mib = -1; | - | ||||||||||||||||||
78 | QByteArray nameList; | - | ||||||||||||||||||
79 | int pos = 0; | - | ||||||||||||||||||
80 | while (!file.atEnd()) { | - | ||||||||||||||||||
81 | QByteArray s = file.readLine().trimmed(); | - | ||||||||||||||||||
82 | if (s.isEmpty()) { | - | ||||||||||||||||||
83 | if (mib != -1) { | - | ||||||||||||||||||
84 | UErrorCode error = U_ZERO_ERROR; | - | ||||||||||||||||||
85 | const char *standard_name = ucnv_getStandardName(name, "MIME", &error); | - | ||||||||||||||||||
86 | if (U_FAILURE(error) || !standard_name) { | - | ||||||||||||||||||
87 | error = U_ZERO_ERROR; | - | ||||||||||||||||||
88 | standard_name = ucnv_getStandardName(name, "IANA", &error); | - | ||||||||||||||||||
89 | } | - | ||||||||||||||||||
90 | UConverter *conv = ucnv_open(standard_name, &error); | - | ||||||||||||||||||
91 | if (!U_FAILURE(error) && conv && standard_name) { | - | ||||||||||||||||||
92 | ucnv_close(conv); | - | ||||||||||||||||||
93 | printf(" { %d, %d },\n", mib, pos); | - | ||||||||||||||||||
94 | nameList += "\""; | - | ||||||||||||||||||
95 | nameList += standard_name; | - | ||||||||||||||||||
96 | nameList += "\\0\"\n"; | - | ||||||||||||||||||
97 | pos += strlen(standard_name) + 1; | - | ||||||||||||||||||
98 | } | - | ||||||||||||||||||
99 | } | - | ||||||||||||||||||
100 | name = QByteArray(); | - | ||||||||||||||||||
101 | mib = -1; | - | ||||||||||||||||||
102 | } | - | ||||||||||||||||||
103 | if (s.startsWith("Name: ")) { | - | ||||||||||||||||||
104 | name = s.mid(5).trimmed(); | - | ||||||||||||||||||
105 | if (name.indexOf(' ') > 0) | - | ||||||||||||||||||
106 | name = name.left(name.indexOf(' ')); | - | ||||||||||||||||||
107 | } | - | ||||||||||||||||||
108 | if (s.startsWith("MIBenum:")) | - | ||||||||||||||||||
109 | mib = s.mid(8).trimmed().toInt(); | - | ||||||||||||||||||
110 | if (s.startsWith("Alias:") && s.contains("MIME")) { | - | ||||||||||||||||||
111 | name = s.mid(6).trimmed(); | - | ||||||||||||||||||
112 | name = name.left(name.indexOf(' ')).trimmed(); | - | ||||||||||||||||||
113 | } | - | ||||||||||||||||||
114 | } | - | ||||||||||||||||||
115 | qDebug() << nameList; | - | ||||||||||||||||||
116 | } | - | ||||||||||||||||||
117 | */ | - | ||||||||||||||||||
118 | - | |||||||||||||||||||
119 | struct MibToName { | - | ||||||||||||||||||
120 | short mib; | - | ||||||||||||||||||
121 | short index; | - | ||||||||||||||||||
122 | }; | - | ||||||||||||||||||
123 | - | |||||||||||||||||||
124 | static const MibToName mibToName[] = { | - | ||||||||||||||||||
125 | { 3, 0 }, | - | ||||||||||||||||||
126 | { 4, 9 }, | - | ||||||||||||||||||
127 | { 5, 20 }, | - | ||||||||||||||||||
128 | { 6, 31 }, | - | ||||||||||||||||||
129 | { 7, 42 }, | - | ||||||||||||||||||
130 | { 8, 53 }, | - | ||||||||||||||||||
131 | { 9, 64 }, | - | ||||||||||||||||||
132 | { 10, 75 }, | - | ||||||||||||||||||
133 | { 11, 86 }, | - | ||||||||||||||||||
134 | { 12, 97 }, | - | ||||||||||||||||||
135 | { 13, 108 }, | - | ||||||||||||||||||
136 | { 16, 120 }, | - | ||||||||||||||||||
137 | { 17, 134 }, | - | ||||||||||||||||||
138 | { 18, 144 }, | - | ||||||||||||||||||
139 | { 30, 151 }, | - | ||||||||||||||||||
140 | { 36, 160 }, | - | ||||||||||||||||||
141 | { 37, 167 }, | - | ||||||||||||||||||
142 | { 38, 179 }, | - | ||||||||||||||||||
143 | { 39, 186 }, | - | ||||||||||||||||||
144 | { 40, 198 }, | - | ||||||||||||||||||
145 | { 57, 212 }, | - | ||||||||||||||||||
146 | { 81, 223 }, | - | ||||||||||||||||||
147 | { 82, 234 }, | - | ||||||||||||||||||
148 | { 84, 245 }, | - | ||||||||||||||||||
149 | { 85, 256 }, | - | ||||||||||||||||||
150 | { 104, 267 }, | - | ||||||||||||||||||
151 | { 105, 279 }, | - | ||||||||||||||||||
152 | { 106, 295 }, | - | ||||||||||||||||||
153 | { 109, 301 }, | - | ||||||||||||||||||
154 | { 110, 313 }, | - | ||||||||||||||||||
155 | { 111, 325 }, | - | ||||||||||||||||||
156 | { 113, 337 }, | - | ||||||||||||||||||
157 | { 114, 341 }, | - | ||||||||||||||||||
158 | { 1000, 349 }, | - | ||||||||||||||||||
159 | { 1001, 356 }, | - | ||||||||||||||||||
160 | { 1011, 363 }, | - | ||||||||||||||||||
161 | { 1012, 368 }, | - | ||||||||||||||||||
162 | { 1013, 374 }, | - | ||||||||||||||||||
163 | { 1014, 383 }, | - | ||||||||||||||||||
164 | { 1015, 392 }, | - | ||||||||||||||||||
165 | { 1016, 399 }, | - | ||||||||||||||||||
166 | { 1017, 406 }, | - | ||||||||||||||||||
167 | { 1018, 413 }, | - | ||||||||||||||||||
168 | { 1019, 422 }, | - | ||||||||||||||||||
169 | { 1020, 431 }, | - | ||||||||||||||||||
170 | { 2004, 438 }, | - | ||||||||||||||||||
171 | { 2005, 448 }, | - | ||||||||||||||||||
172 | { 2009, 472 }, | - | ||||||||||||||||||
173 | { 2013, 479 }, | - | ||||||||||||||||||
174 | { 2016, 486 }, | - | ||||||||||||||||||
175 | { 2024, 495 }, | - | ||||||||||||||||||
176 | { 2025, 505 }, | - | ||||||||||||||||||
177 | { 2026, 512 }, | - | ||||||||||||||||||
178 | { 2027, 517 }, | - | ||||||||||||||||||
179 | { 2028, 527 }, | - | ||||||||||||||||||
180 | { 2030, 534 }, | - | ||||||||||||||||||
181 | { 2033, 541 }, | - | ||||||||||||||||||
182 | { 2034, 548 }, | - | ||||||||||||||||||
183 | { 2035, 555 }, | - | ||||||||||||||||||
184 | { 2037, 562 }, | - | ||||||||||||||||||
185 | { 2038, 569 }, | - | ||||||||||||||||||
186 | { 2039, 576 }, | - | ||||||||||||||||||
187 | { 2040, 583 }, | - | ||||||||||||||||||
188 | { 2041, 590 }, | - | ||||||||||||||||||
189 | { 2043, 597 }, | - | ||||||||||||||||||
190 | { 2011, 604 }, | - | ||||||||||||||||||
191 | { 2044, 611 }, | - | ||||||||||||||||||
192 | { 2045, 618 }, | - | ||||||||||||||||||
193 | { 2010, 624 }, | - | ||||||||||||||||||
194 | { 2046, 631 }, | - | ||||||||||||||||||
195 | { 2047, 638 }, | - | ||||||||||||||||||
196 | { 2048, 645 }, | - | ||||||||||||||||||
197 | { 2049, 652 }, | - | ||||||||||||||||||
198 | { 2050, 659 }, | - | ||||||||||||||||||
199 | { 2051, 666 }, | - | ||||||||||||||||||
200 | { 2052, 673 }, | - | ||||||||||||||||||
201 | { 2053, 680 }, | - | ||||||||||||||||||
202 | { 2054, 687 }, | - | ||||||||||||||||||
203 | { 2055, 694 }, | - | ||||||||||||||||||
204 | { 2056, 701 }, | - | ||||||||||||||||||
205 | { 2062, 708 }, | - | ||||||||||||||||||
206 | { 2063, 715 }, | - | ||||||||||||||||||
207 | { 2084, 723 }, | - | ||||||||||||||||||
208 | { 2085, 730 }, | - | ||||||||||||||||||
209 | { 2086, 741 }, | - | ||||||||||||||||||
210 | { 2087, 748 }, | - | ||||||||||||||||||
211 | { 2088, 755 }, | - | ||||||||||||||||||
212 | { 2089, 762 }, | - | ||||||||||||||||||
213 | { 2091, 771 }, | - | ||||||||||||||||||
214 | { 2092, 780 }, | - | ||||||||||||||||||
215 | { 2093, 789 }, | - | ||||||||||||||||||
216 | { 2094, 798 }, | - | ||||||||||||||||||
217 | { 2095, 807 }, | - | ||||||||||||||||||
218 | { 2096, 816 }, | - | ||||||||||||||||||
219 | { 2097, 825 }, | - | ||||||||||||||||||
220 | { 2098, 834 }, | - | ||||||||||||||||||
221 | { 2099, 843 }, | - | ||||||||||||||||||
222 | { 2100, 852 }, | - | ||||||||||||||||||
223 | { 2101, 861 }, | - | ||||||||||||||||||
224 | { 2102, 872 }, | - | ||||||||||||||||||
225 | { 2250, 880 }, | - | ||||||||||||||||||
226 | { 2251, 893 }, | - | ||||||||||||||||||
227 | { 2252, 906 }, | - | ||||||||||||||||||
228 | { 2253, 919 }, | - | ||||||||||||||||||
229 | { 2254, 932 }, | - | ||||||||||||||||||
230 | { 2255, 945 }, | - | ||||||||||||||||||
231 | { 2256, 958 }, | - | ||||||||||||||||||
232 | { 2257, 971 }, | - | ||||||||||||||||||
233 | { 2258, 984 }, | - | ||||||||||||||||||
234 | { 2259, 997 }, | - | ||||||||||||||||||
235 | }; | - | ||||||||||||||||||
236 | int mibToNameSize = sizeof(mibToName)/sizeof(MibToName); | - | ||||||||||||||||||
237 | - | |||||||||||||||||||
238 | static const char mibToNameTable[] = | - | ||||||||||||||||||
239 | "US-ASCII\0" | - | ||||||||||||||||||
240 | "ISO-8859-1\0" | - | ||||||||||||||||||
241 | "ISO-8859-2\0" | - | ||||||||||||||||||
242 | "ISO-8859-3\0" | - | ||||||||||||||||||
243 | "ISO-8859-4\0" | - | ||||||||||||||||||
244 | "ISO-8859-5\0" | - | ||||||||||||||||||
245 | "ISO-8859-6\0" | - | ||||||||||||||||||
246 | "ISO-8859-7\0" | - | ||||||||||||||||||
247 | "ISO-8859-8\0" | - | ||||||||||||||||||
248 | "ISO-8859-9\0" | - | ||||||||||||||||||
249 | "ISO-8859-10\0" | - | ||||||||||||||||||
250 | "ISO-2022-JP-1\0" | - | ||||||||||||||||||
251 | "Shift_JIS\0" | - | ||||||||||||||||||
252 | "EUC-JP\0" | - | ||||||||||||||||||
253 | "US-ASCII\0" | - | ||||||||||||||||||
254 | "EUC-KR\0" | - | ||||||||||||||||||
255 | "ISO-2022-KR\0" | - | ||||||||||||||||||
256 | "EUC-KR\0" | - | ||||||||||||||||||
257 | "ISO-2022-JP\0" | - | ||||||||||||||||||
258 | "ISO-2022-JP-2\0" | - | ||||||||||||||||||
259 | "GB_2312-80\0" | - | ||||||||||||||||||
260 | "ISO-8859-6\0" | - | ||||||||||||||||||
261 | "ISO-8859-6\0" | - | ||||||||||||||||||
262 | "ISO-8859-8\0" | - | ||||||||||||||||||
263 | "ISO-8859-8\0" | - | ||||||||||||||||||
264 | "ISO-2022-CN\0" | - | ||||||||||||||||||
265 | "ISO-2022-CN-EXT\0" | - | ||||||||||||||||||
266 | "UTF-8\0" | - | ||||||||||||||||||
267 | "ISO-8859-13\0" | - | ||||||||||||||||||
268 | "ISO-8859-14\0" | - | ||||||||||||||||||
269 | "ISO-8859-15\0" | - | ||||||||||||||||||
270 | "GBK\0" | - | ||||||||||||||||||
271 | "GB18030\0" | - | ||||||||||||||||||
272 | "UTF-16\0" | - | ||||||||||||||||||
273 | "UTF-32\0" | - | ||||||||||||||||||
274 | "SCSU\0" | - | ||||||||||||||||||
275 | "UTF-7\0" | - | ||||||||||||||||||
276 | "UTF-16BE\0" | - | ||||||||||||||||||
277 | "UTF-16LE\0" | - | ||||||||||||||||||
278 | "UTF-16\0" | - | ||||||||||||||||||
279 | "CESU-8\0" | - | ||||||||||||||||||
280 | "UTF-32\0" | - | ||||||||||||||||||
281 | "UTF-32BE\0" | - | ||||||||||||||||||
282 | "UTF-32LE\0" | - | ||||||||||||||||||
283 | "BOCU-1\0" | - | ||||||||||||||||||
284 | "hp-roman8\0" | - | ||||||||||||||||||
285 | "Adobe-Standard-Encoding\0" | - | ||||||||||||||||||
286 | "IBM850\0" | - | ||||||||||||||||||
287 | "IBM862\0" | - | ||||||||||||||||||
288 | "IBM-Thai\0" | - | ||||||||||||||||||
289 | "Shift_JIS\0" | - | ||||||||||||||||||
290 | "GB2312\0" | - | ||||||||||||||||||
291 | "Big5\0" | - | ||||||||||||||||||
292 | "macintosh\0" | - | ||||||||||||||||||
293 | "IBM037\0" | - | ||||||||||||||||||
294 | "IBM273\0" | - | ||||||||||||||||||
295 | "IBM277\0" | - | ||||||||||||||||||
296 | "IBM278\0" | - | ||||||||||||||||||
297 | "IBM280\0" | - | ||||||||||||||||||
298 | "IBM284\0" | - | ||||||||||||||||||
299 | "IBM285\0" | - | ||||||||||||||||||
300 | "IBM290\0" | - | ||||||||||||||||||
301 | "IBM297\0" | - | ||||||||||||||||||
302 | "IBM420\0" | - | ||||||||||||||||||
303 | "IBM424\0" | - | ||||||||||||||||||
304 | "IBM437\0" | - | ||||||||||||||||||
305 | "IBM500\0" | - | ||||||||||||||||||
306 | "cp851\0" | - | ||||||||||||||||||
307 | "IBM852\0" | - | ||||||||||||||||||
308 | "IBM855\0" | - | ||||||||||||||||||
309 | "IBM857\0" | - | ||||||||||||||||||
310 | "IBM860\0" | - | ||||||||||||||||||
311 | "IBM861\0" | - | ||||||||||||||||||
312 | "IBM863\0" | - | ||||||||||||||||||
313 | "IBM864\0" | - | ||||||||||||||||||
314 | "IBM865\0" | - | ||||||||||||||||||
315 | "IBM868\0" | - | ||||||||||||||||||
316 | "IBM869\0" | - | ||||||||||||||||||
317 | "IBM870\0" | - | ||||||||||||||||||
318 | "IBM871\0" | - | ||||||||||||||||||
319 | "IBM918\0" | - | ||||||||||||||||||
320 | "IBM1026\0" | - | ||||||||||||||||||
321 | "KOI8-R\0" | - | ||||||||||||||||||
322 | "HZ-GB-2312\0" | - | ||||||||||||||||||
323 | "IBM866\0" | - | ||||||||||||||||||
324 | "IBM775\0" | - | ||||||||||||||||||
325 | "KOI8-U\0" | - | ||||||||||||||||||
326 | "IBM00858\0" | - | ||||||||||||||||||
327 | "IBM01140\0" | - | ||||||||||||||||||
328 | "IBM01141\0" | - | ||||||||||||||||||
329 | "IBM01142\0" | - | ||||||||||||||||||
330 | "IBM01143\0" | - | ||||||||||||||||||
331 | "IBM01144\0" | - | ||||||||||||||||||
332 | "IBM01145\0" | - | ||||||||||||||||||
333 | "IBM01146\0" | - | ||||||||||||||||||
334 | "IBM01147\0" | - | ||||||||||||||||||
335 | "IBM01148\0" | - | ||||||||||||||||||
336 | "IBM01149\0" | - | ||||||||||||||||||
337 | "Big5-HKSCS\0" | - | ||||||||||||||||||
338 | "IBM1047\0" | - | ||||||||||||||||||
339 | "windows-1250\0" | - | ||||||||||||||||||
340 | "windows-1251\0" | - | ||||||||||||||||||
341 | "windows-1252\0" | - | ||||||||||||||||||
342 | "windows-1253\0" | - | ||||||||||||||||||
343 | "windows-1254\0" | - | ||||||||||||||||||
344 | "windows-1255\0" | - | ||||||||||||||||||
345 | "windows-1256\0" | - | ||||||||||||||||||
346 | "windows-1257\0" | - | ||||||||||||||||||
347 | "windows-1258\0" | - | ||||||||||||||||||
348 | "TIS-620\0"; | - | ||||||||||||||||||
349 | - | |||||||||||||||||||
350 | static QTextCodec *loadQtCodec(const char *name) | - | ||||||||||||||||||
351 | { | - | ||||||||||||||||||
352 | if (!strcmp(name, "UTF-8"))
| 309-822 | ||||||||||||||||||
353 | return new QUtf8Codec; executed 309 times by 14 tests: return new QUtf8Codec; Executed by:
| 309 | ||||||||||||||||||
354 | if (!strcmp(name, "UTF-16"))
| 6-816 | ||||||||||||||||||
355 | return new QUtf16Codec; executed 6 times by 6 tests: return new QUtf16Codec; Executed by:
| 6 | ||||||||||||||||||
356 | if (!strcmp(name, "ISO-8859-1"))
| 6-810 | ||||||||||||||||||
357 | return new QLatin1Codec; executed 6 times by 6 tests: return new QLatin1Codec; Executed by:
| 6 | ||||||||||||||||||
358 | if (!strcmp(name, "UTF-16BE"))
| 3-807 | ||||||||||||||||||
359 | return new QUtf16BECodec; executed 3 times by 3 tests: return new QUtf16BECodec; Executed by:
| 3 | ||||||||||||||||||
360 | if (!strcmp(name, "UTF-16LE"))
| 4-803 | ||||||||||||||||||
361 | return new QUtf16LECodec; executed 4 times by 4 tests: return new QUtf16LECodec; Executed by:
| 4 | ||||||||||||||||||
362 | if (!strcmp(name, "UTF-32"))
| 1-802 | ||||||||||||||||||
363 | return new QUtf32Codec; executed 1 time by 1 test: return new QUtf32Codec; Executed by:
| 1 | ||||||||||||||||||
364 | if (!strcmp(name, "UTF-32BE"))
| 2-800 | ||||||||||||||||||
365 | return new QUtf32BECodec; executed 2 times by 2 tests: return new QUtf32BECodec; Executed by:
| 2 | ||||||||||||||||||
366 | if (!strcmp(name, "UTF-32LE"))
| 2-798 | ||||||||||||||||||
367 | return new QUtf32LECodec; executed 2 times by 2 tests: return new QUtf32LECodec; Executed by:
| 2 | ||||||||||||||||||
368 | if (!strcmp(name, "ISO-8859-16") || !strcmp(name, "latin10") || !strcmp(name, "iso-ir-226"))
| 0-797 | ||||||||||||||||||
369 | return new QSimpleTextCodec(13 /* == 8859-16*/); executed 1 time by 1 test: return new QSimpleTextCodec(13 ); Executed by:
| 1 | ||||||||||||||||||
370 | #ifndef QT_NO_CODECS | - | ||||||||||||||||||
371 | if (!strcmp(name, "TSCII"))
| 1-796 | ||||||||||||||||||
372 | return new QTsciiCodec; executed 1 time by 1 test: return new QTsciiCodec; Executed by:
| 1 | ||||||||||||||||||
373 | if (!qstrnicmp(name, "iscii", 5))
| 9-787 | ||||||||||||||||||
374 | return QIsciiCodec::create(name); executed 9 times by 1 test: return QIsciiCodec::create(name); Executed by:
| 9 | ||||||||||||||||||
375 | #endif | - | ||||||||||||||||||
376 | - | |||||||||||||||||||
377 | return 0; executed 787 times by 7 tests: return 0; Executed by:
| 787 | ||||||||||||||||||
378 | } | - | ||||||||||||||||||
379 | - | |||||||||||||||||||
380 | /// \threadsafe | - | ||||||||||||||||||
381 | QList<QByteArray> QIcuCodec::availableCodecs() | - | ||||||||||||||||||
382 | { | - | ||||||||||||||||||
383 | QList<QByteArray> codecs; | - | ||||||||||||||||||
384 | int n = ucnv_countAvailable(); | - | ||||||||||||||||||
385 | for (int i = 0; i < n; ++i) {
| 4-920 | ||||||||||||||||||
386 | const char *name = ucnv_getAvailableName(i); | - | ||||||||||||||||||
387 | - | |||||||||||||||||||
388 | UErrorCode error = U_ZERO_ERROR; | - | ||||||||||||||||||
389 | const char *standardName = ucnv_getStandardName(name, "MIME", &error); | - | ||||||||||||||||||
390 | if (U_FAILURE(error) || !standardName) {
| 0-920 | ||||||||||||||||||
391 | error = U_ZERO_ERROR; | - | ||||||||||||||||||
392 | standardName = ucnv_getStandardName(name, "IANA", &error); | - | ||||||||||||||||||
393 | } executed 720 times by 1 test: end of block Executed by:
| 720 | ||||||||||||||||||
394 | if (U_FAILURE(error))
| 0-920 | ||||||||||||||||||
395 | continue; never executed: continue; | 0 | ||||||||||||||||||
396 | - | |||||||||||||||||||
397 | error = U_ZERO_ERROR; | - | ||||||||||||||||||
398 | int ac = ucnv_countAliases(standardName, &error); | - | ||||||||||||||||||
399 | if (U_FAILURE(error))
| 428-492 | ||||||||||||||||||
400 | continue; executed 492 times by 1 test: continue; Executed by:
| 492 | ||||||||||||||||||
401 | for (int j = 0; j < ac; ++j) {
| 428-3216 | ||||||||||||||||||
402 | error = U_ZERO_ERROR; | - | ||||||||||||||||||
403 | const char *alias = ucnv_getAlias(standardName, j, &error); | - | ||||||||||||||||||
404 | if (!U_SUCCESS(error))
| 0-3216 | ||||||||||||||||||
405 | continue; never executed: continue; | 0 | ||||||||||||||||||
406 | codecs += alias; | - | ||||||||||||||||||
407 | } executed 3216 times by 1 test: end of block Executed by:
| 3216 | ||||||||||||||||||
408 | } executed 428 times by 1 test: end of block Executed by:
| 428 | ||||||||||||||||||
409 | - | |||||||||||||||||||
410 | // handled by Qt and not in ICU: | - | ||||||||||||||||||
411 | codecs += "TSCII"; | - | ||||||||||||||||||
412 | - | |||||||||||||||||||
413 | return codecs; executed 4 times by 1 test: return codecs; Executed by:
| 4 | ||||||||||||||||||
414 | } | - | ||||||||||||||||||
415 | - | |||||||||||||||||||
416 | /// \threadsafe | - | ||||||||||||||||||
417 | QList<int> QIcuCodec::availableMibs() | - | ||||||||||||||||||
418 | { | - | ||||||||||||||||||
419 | QList<int> mibs; | - | ||||||||||||||||||
420 | mibs.reserve(mibToNameSize + 1); | - | ||||||||||||||||||
421 | for (int i = 0; i < mibToNameSize; ++i)
| 2-220 | ||||||||||||||||||
422 | mibs += mibToName[i].mib; executed 220 times by 1 test: mibs += mibToName[i].mib; Executed by:
| 220 | ||||||||||||||||||
423 | - | |||||||||||||||||||
424 | // handled by Qt and not in ICU: | - | ||||||||||||||||||
425 | mibs += 2107; // TSCII | - | ||||||||||||||||||
426 | - | |||||||||||||||||||
427 | return mibs; executed 2 times by 1 test: return mibs; Executed by:
| 2 | ||||||||||||||||||
428 | } | - | ||||||||||||||||||
429 | - | |||||||||||||||||||
430 | QTextCodec *QIcuCodec::defaultCodecUnlocked() | - | ||||||||||||||||||
431 | { | - | ||||||||||||||||||
432 | QCoreGlobalData *globalData = QCoreGlobalData::instance(); | - | ||||||||||||||||||
433 | if (!globalData)
| 0-981 | ||||||||||||||||||
434 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
435 | QTextCodec *c = globalData->codecForLocale.loadAcquire(); | - | ||||||||||||||||||
436 | if (c)
| 0-981 | ||||||||||||||||||
437 | return c; never executed: return c; | 0 | ||||||||||||||||||
438 | - | |||||||||||||||||||
439 | #if defined(QT_LOCALE_IS_UTF8) | - | ||||||||||||||||||
440 | const char *name = "UTF-8"; | - | ||||||||||||||||||
441 | #else | - | ||||||||||||||||||
442 | const char *name = ucnv_getDefaultName(); | - | ||||||||||||||||||
443 | #endif | - | ||||||||||||||||||
444 | c = codecForNameUnlocked(name); | - | ||||||||||||||||||
445 | globalData->codecForLocale.storeRelease(c); | - | ||||||||||||||||||
446 | return c; executed 981 times by 15 tests: return c; Executed by:
| 981 | ||||||||||||||||||
447 | } | - | ||||||||||||||||||
448 | - | |||||||||||||||||||
449 | - | |||||||||||||||||||
450 | QTextCodec *QIcuCodec::codecForNameUnlocked(const char *name) | - | ||||||||||||||||||
451 | { | - | ||||||||||||||||||
452 | // backwards compatibility with Qt 4.x | - | ||||||||||||||||||
453 | if (!qstrcmp(name, "CP949"))
| 1-19900 | ||||||||||||||||||
454 | name = "windows-949"; executed 1 time by 1 test: name = "windows-949"; Executed by:
| 1 | ||||||||||||||||||
455 | else if (!qstrcmp(name, "Apple Roman"))
| 1-19899 | ||||||||||||||||||
456 | name = "macintosh"; executed 1 time by 1 test: name = "macintosh"; Executed by:
| 1 | ||||||||||||||||||
457 | // these are broken data in ICU 4.4, and can't be resolved even though they are aliases to tis-620 | - | ||||||||||||||||||
458 | if (!qstrcmp(name, "windows-874-2000")
| 15-19886 | ||||||||||||||||||
459 | || !qstrcmp(name, "windows-874")
| 15-19871 | ||||||||||||||||||
460 | || !qstrcmp(name, "MS874")
| 15-19856 | ||||||||||||||||||
461 | || !qstrcmp(name, "x-windows-874")
| 15-19841 | ||||||||||||||||||
462 | || !qstrcmp(name, "ISO 8859-11"))
| 0-19841 | ||||||||||||||||||
463 | name = "TIS-620"; executed 60 times by 1 test: name = "TIS-620"; Executed by:
| 60 | ||||||||||||||||||
464 | - | |||||||||||||||||||
465 | UErrorCode error = U_ZERO_ERROR; | - | ||||||||||||||||||
466 | // MIME gives better default names | - | ||||||||||||||||||
467 | const char *standardName = ucnv_getStandardName(name, "MIME", &error); | - | ||||||||||||||||||
468 | if (U_FAILURE(error) || !standardName) {
| 1-19900 | ||||||||||||||||||
469 | error = U_ZERO_ERROR; | - | ||||||||||||||||||
470 | standardName = ucnv_getStandardName(name, "IANA", &error); | - | ||||||||||||||||||
471 | } executed 6452 times by 4 tests: end of block Executed by:
| 6452 | ||||||||||||||||||
472 | bool qt_only = false; | - | ||||||||||||||||||
473 | if (U_FAILURE(error) || !standardName) {
| 1-19900 | ||||||||||||||||||
474 | standardName = name; | - | ||||||||||||||||||
475 | qt_only = true; | - | ||||||||||||||||||
476 | } else { executed 60 times by 2 tests: end of block Executed by:
| 60 | ||||||||||||||||||
477 | // correct some issues where the ICU data set contains duplicated entries. | - | ||||||||||||||||||
478 | // Where this happens it's because one data set is a subset of another. We | - | ||||||||||||||||||
479 | // always use the larger data set. | - | ||||||||||||||||||
480 | - | |||||||||||||||||||
481 | if (qstrcmp(standardName, "GB2312") == 0 || qstrcmp(standardName, "GB_2312-80") == 0)
| 25-19809 | ||||||||||||||||||
482 | standardName = "GBK"; executed 57 times by 1 test: standardName = "GBK"; Executed by:
| 57 | ||||||||||||||||||
483 | else if (qstrcmp(standardName, "KSC_5601") == 0 || qstrcmp(standardName, "EUC-KR") == 0 || qstrcmp(standardName, "cp1363") == 0)
| 18-19235 | ||||||||||||||||||
484 | standardName = "windows-949"; executed 607 times by 1 test: standardName = "windows-949"; Executed by:
| 607 | ||||||||||||||||||
485 | } executed 19841 times by 31 tests: end of block Executed by:
| 19841 | ||||||||||||||||||
486 | - | |||||||||||||||||||
487 | QCoreGlobalData *globalData = QCoreGlobalData::instance(); | - | ||||||||||||||||||
488 | QTextCodecCache *cache = &globalData->codecCache; | - | ||||||||||||||||||
489 | - | |||||||||||||||||||
490 | QTextCodec *codec; | - | ||||||||||||||||||
491 | if (cache) {
| 0-19901 | ||||||||||||||||||
492 | codec = cache->value(standardName); | - | ||||||||||||||||||
493 | if (codec)
| 1293-18608 | ||||||||||||||||||
494 | return codec; executed 18608 times by 13 tests: return codec; Executed by:
| 18608 | ||||||||||||||||||
495 | } executed 1293 times by 31 tests: end of block Executed by:
| 1293 | ||||||||||||||||||
496 | - | |||||||||||||||||||
497 | for (TextCodecListConstIt it = globalData->allCodecs.constBegin(), cend = globalData->allCodecs.constEnd(); it != cend; ++it) {
| 1131-7970 | ||||||||||||||||||
498 | QTextCodec *cursor = *it; | - | ||||||||||||||||||
499 | if (qTextCodecNameMatch(cursor->name(), standardName)) {
| 162-7808 | ||||||||||||||||||
500 | if (cache)
| 0-162 | ||||||||||||||||||
501 | cache->insert(standardName, cursor); executed 162 times by 16 tests: cache->insert(standardName, cursor); Executed by:
| 162 | ||||||||||||||||||
502 | return cursor; executed 162 times by 16 tests: return cursor; Executed by:
| 162 | ||||||||||||||||||
503 | } | - | ||||||||||||||||||
504 | QList<QByteArray> aliases = cursor->aliases(); | - | ||||||||||||||||||
505 | for (ByteArrayListConstIt ait = aliases.constBegin(), acend = aliases.constEnd(); ait != acend; ++ait) {
| 7808-42656 | ||||||||||||||||||
506 | if (qTextCodecNameMatch(*ait, standardName)) {
| 0-42656 | ||||||||||||||||||
507 | if (cache)
| 0 | ||||||||||||||||||
508 | cache->insert(standardName, cursor); never executed: cache->insert(standardName, cursor); | 0 | ||||||||||||||||||
509 | return cursor; never executed: return cursor; | 0 | ||||||||||||||||||
510 | } | - | ||||||||||||||||||
511 | } executed 42656 times by 8 tests: end of block Executed by:
| 42656 | ||||||||||||||||||
512 | } executed 7808 times by 10 tests: end of block Executed by:
| 7808 | ||||||||||||||||||
513 | - | |||||||||||||||||||
514 | QTextCodec *c = loadQtCodec(standardName); | - | ||||||||||||||||||
515 | if (c)
| 344-787 | ||||||||||||||||||
516 | return c; executed 344 times by 22 tests: return c; Executed by:
| 344 | ||||||||||||||||||
517 | - | |||||||||||||||||||
518 | if (qt_only)
| 12-775 | ||||||||||||||||||
519 | return 0; executed 12 times by 2 tests: return 0; Executed by:
| 12 | ||||||||||||||||||
520 | - | |||||||||||||||||||
521 | // check whether there is really a converter for the name available. | - | ||||||||||||||||||
522 | UConverter *conv = ucnv_open(standardName, &error); | - | ||||||||||||||||||
523 | if (!conv) {
| 0-775 | ||||||||||||||||||
524 | qDebug() << "codecForName: ucnv_open failed" << standardName << u_errorName(error); | - | ||||||||||||||||||
525 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
526 | } | - | ||||||||||||||||||
527 | //qDebug() << "QIcuCodec: Standard name for " << name << "is" << standardName; | - | ||||||||||||||||||
528 | ucnv_close(conv); | - | ||||||||||||||||||
529 | - | |||||||||||||||||||
530 | - | |||||||||||||||||||
531 | c = new QIcuCodec(standardName); | - | ||||||||||||||||||
532 | if (cache)
| 0-775 | ||||||||||||||||||
533 | cache->insert(standardName, c); executed 775 times by 7 tests: cache->insert(standardName, c); Executed by:
| 775 | ||||||||||||||||||
534 | return c; executed 775 times by 7 tests: return c; Executed by:
| 775 | ||||||||||||||||||
535 | } | - | ||||||||||||||||||
536 | - | |||||||||||||||||||
537 | - | |||||||||||||||||||
538 | QTextCodec *QIcuCodec::codecForMibUnlocked(int mib) | - | ||||||||||||||||||
539 | { | - | ||||||||||||||||||
540 | for (int i = 0; i < mibToNameSize; ++i) {
| 0-752 | ||||||||||||||||||
541 | if (mibToName[i].mib == mib)
| 23-729 | ||||||||||||||||||
542 | return codecForNameUnlocked(mibToNameTable + mibToName[i].index); executed 23 times by 5 tests: return codecForNameUnlocked(mibToNameTable + mibToName[i].index); Executed by:
| 23 | ||||||||||||||||||
543 | } executed 729 times by 5 tests: end of block Executed by:
| 729 | ||||||||||||||||||
544 | - | |||||||||||||||||||
545 | if (mib == 2107)
| 0 | ||||||||||||||||||
546 | return codecForNameUnlocked("TSCII"); never executed: return codecForNameUnlocked("TSCII"); | 0 | ||||||||||||||||||
547 | - | |||||||||||||||||||
548 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
549 | } | - | ||||||||||||||||||
550 | - | |||||||||||||||||||
551 | - | |||||||||||||||||||
552 | QIcuCodec::QIcuCodec(const char *name) | - | ||||||||||||||||||
553 | : m_name(name) | - | ||||||||||||||||||
554 | { | - | ||||||||||||||||||
555 | } executed 775 times by 7 tests: end of block Executed by:
| 775 | ||||||||||||||||||
556 | - | |||||||||||||||||||
557 | QIcuCodec::~QIcuCodec() | - | ||||||||||||||||||
558 | { | - | ||||||||||||||||||
559 | } | - | ||||||||||||||||||
560 | - | |||||||||||||||||||
561 | UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const | - | ||||||||||||||||||
562 | { | - | ||||||||||||||||||
563 | UConverter *conv = 0; | - | ||||||||||||||||||
564 | if (state) {
| 137-47833 | ||||||||||||||||||
565 | if (!state->d) {
| 14-123 | ||||||||||||||||||
566 | // first time | - | ||||||||||||||||||
567 | state->flags |= QTextCodec::FreeFunction; | - | ||||||||||||||||||
568 | QTextCodecUnalignedPointer::encode(state->state_data, qIcuCodecStateFree); | - | ||||||||||||||||||
569 | UErrorCode error = U_ZERO_ERROR; | - | ||||||||||||||||||
570 | state->d = ucnv_open(m_name, &error); | - | ||||||||||||||||||
571 | ucnv_setSubstChars(static_cast<UConverter *>(state->d), | - | ||||||||||||||||||
572 | state->flags & QTextCodec::ConvertInvalidToNull ? "\0" : "?", 1, &error); | - | ||||||||||||||||||
573 | if (U_FAILURE(error))
| 0-14 | ||||||||||||||||||
574 | qDebug() << "getConverter(state) ucnv_open failed" << m_name << u_errorName(error); never executed: QMessageLogger(__FILE__, 574, __PRETTY_FUNCTION__).debug() << "getConverter(state) ucnv_open failed" << m_name << u_errorName_52(error); | 0 | ||||||||||||||||||
575 | } executed 14 times by 3 tests: end of block Executed by:
| 14 | ||||||||||||||||||
576 | conv = static_cast<UConverter *>(state->d); | - | ||||||||||||||||||
577 | } executed 137 times by 3 tests: end of block Executed by:
| 137 | ||||||||||||||||||
578 | if (!conv) {
| 137-47833 | ||||||||||||||||||
579 | // stateless conversion | - | ||||||||||||||||||
580 | UErrorCode error = U_ZERO_ERROR; | - | ||||||||||||||||||
581 | conv = ucnv_open(m_name, &error); | - | ||||||||||||||||||
582 | ucnv_setSubstChars(conv, "?", 1, &error); | - | ||||||||||||||||||
583 | if (U_FAILURE(error))
| 0-47833 | ||||||||||||||||||
584 | qDebug() << "getConverter(no state) ucnv_open failed" << m_name << u_errorName(error); never executed: QMessageLogger(__FILE__, 584, __PRETTY_FUNCTION__).debug() << "getConverter(no state) ucnv_open failed" << m_name << u_errorName_52(error); | 0 | ||||||||||||||||||
585 | } executed 47833 times by 7 tests: end of block Executed by:
| 47833 | ||||||||||||||||||
586 | return conv; executed 47970 times by 9 tests: return conv; Executed by:
| 47970 | ||||||||||||||||||
587 | } | - | ||||||||||||||||||
588 | - | |||||||||||||||||||
589 | QString QIcuCodec::convertToUnicode(const char *chars, int length, QTextCodec::ConverterState *state) const | - | ||||||||||||||||||
590 | { | - | ||||||||||||||||||
591 | UConverter *conv = getConverter(state); | - | ||||||||||||||||||
592 | - | |||||||||||||||||||
593 | QString string(length + 2, Qt::Uninitialized); | - | ||||||||||||||||||
594 | - | |||||||||||||||||||
595 | const char *end = chars + length; | - | ||||||||||||||||||
596 | int convertedChars = 0; | - | ||||||||||||||||||
597 | while (1) { | - | ||||||||||||||||||
598 | UChar *uc = (UChar *)string.data(); | - | ||||||||||||||||||
599 | UChar *ucEnd = uc + string.length(); | - | ||||||||||||||||||
600 | uc += convertedChars; | - | ||||||||||||||||||
601 | UErrorCode error = U_ZERO_ERROR; | - | ||||||||||||||||||
602 | ucnv_toUnicode(conv, | - | ||||||||||||||||||
603 | &uc, ucEnd, | - | ||||||||||||||||||
604 | &chars, end, | - | ||||||||||||||||||
605 | 0, false, &error); | - | ||||||||||||||||||
606 | if (!U_SUCCESS(error) && error != U_BUFFER_OVERFLOW_ERROR) {
| 0-13034 | ||||||||||||||||||
607 | qDebug() << "convertToUnicode failed:" << u_errorName(error); | - | ||||||||||||||||||
608 | break; never executed: break; | 0 | ||||||||||||||||||
609 | } | - | ||||||||||||||||||
610 | - | |||||||||||||||||||
611 | convertedChars = uc - (UChar *)string.data(); | - | ||||||||||||||||||
612 | if (chars >= end)
| 0-13034 | ||||||||||||||||||
613 | break; executed 13034 times by 8 tests: break; Executed by:
| 13034 | ||||||||||||||||||
614 | string.resize(string.length()*2); | - | ||||||||||||||||||
615 | } never executed: end of block | 0 | ||||||||||||||||||
616 | string.resize(convertedChars); | - | ||||||||||||||||||
617 | - | |||||||||||||||||||
618 | if (!state)
| 115-12919 | ||||||||||||||||||
619 | ucnv_close(conv); executed 12919 times by 6 tests: ucnv_close_52(conv); Executed by:
| 12919 | ||||||||||||||||||
620 | return string; executed 13034 times by 8 tests: return string; Executed by:
| 13034 | ||||||||||||||||||
621 | } | - | ||||||||||||||||||
622 | - | |||||||||||||||||||
623 | - | |||||||||||||||||||
624 | QByteArray QIcuCodec::convertFromUnicode(const QChar *unicode, int length, QTextCodec::ConverterState *state) const | - | ||||||||||||||||||
625 | { | - | ||||||||||||||||||
626 | UConverter *conv = getConverter(state); | - | ||||||||||||||||||
627 | - | |||||||||||||||||||
628 | int requiredLength = UCNV_GET_MAX_BYTES_FOR_STRING(length, ucnv_getMaxCharSize(conv)); | - | ||||||||||||||||||
629 | QByteArray string(requiredLength, Qt::Uninitialized); | - | ||||||||||||||||||
630 | - | |||||||||||||||||||
631 | const UChar *uc = (const UChar *)unicode; | - | ||||||||||||||||||
632 | const UChar *end = uc + length; | - | ||||||||||||||||||
633 | int convertedChars = 0; | - | ||||||||||||||||||
634 | while (1) { | - | ||||||||||||||||||
635 | char *ch = (char *)string.data(); | - | ||||||||||||||||||
636 | char *chEnd = ch + string.length(); | - | ||||||||||||||||||
637 | ch += convertedChars; | - | ||||||||||||||||||
638 | UErrorCode error = U_ZERO_ERROR; | - | ||||||||||||||||||
639 | ucnv_fromUnicode(conv, | - | ||||||||||||||||||
640 | &ch, chEnd, | - | ||||||||||||||||||
641 | &uc, end, | - | ||||||||||||||||||
642 | 0, false, &error); | - | ||||||||||||||||||
643 | if (!U_SUCCESS(error))
| 0-34936 | ||||||||||||||||||
644 | qDebug() << "convertFromUnicode failed:" << u_errorName(error); never executed: QMessageLogger(__FILE__, 644, __PRETTY_FUNCTION__).debug() << "convertFromUnicode failed:" << u_errorName_52(error); | 0 | ||||||||||||||||||
645 | convertedChars = ch - string.data(); | - | ||||||||||||||||||
646 | if (uc >= end)
| 0-34936 | ||||||||||||||||||
647 | break; executed 34936 times by 7 tests: break; Executed by:
| 34936 | ||||||||||||||||||
648 | string.resize(string.length()*2); | - | ||||||||||||||||||
649 | } never executed: end of block | 0 | ||||||||||||||||||
650 | string.resize(convertedChars); | - | ||||||||||||||||||
651 | - | |||||||||||||||||||
652 | if (!state)
| 22-34914 | ||||||||||||||||||
653 | ucnv_close(conv); executed 34914 times by 6 tests: ucnv_close_52(conv); Executed by:
| 34914 | ||||||||||||||||||
654 | - | |||||||||||||||||||
655 | return string; executed 34936 times by 7 tests: return string; Executed by:
| 34936 | ||||||||||||||||||
656 | } | - | ||||||||||||||||||
657 | - | |||||||||||||||||||
658 | - | |||||||||||||||||||
659 | QByteArray QIcuCodec::name() const | - | ||||||||||||||||||
660 | { | - | ||||||||||||||||||
661 | return m_name; executed 8252 times by 5 tests: return m_name; Executed by:
| 8252 | ||||||||||||||||||
662 | } | - | ||||||||||||||||||
663 | - | |||||||||||||||||||
664 | - | |||||||||||||||||||
665 | QList<QByteArray> QIcuCodec::aliases() const | - | ||||||||||||||||||
666 | { | - | ||||||||||||||||||
667 | UErrorCode error = U_ZERO_ERROR; | - | ||||||||||||||||||
668 | - | |||||||||||||||||||
669 | int n = ucnv_countAliases(m_name, &error); | - | ||||||||||||||||||
670 | - | |||||||||||||||||||
671 | QList<QByteArray> aliases; | - | ||||||||||||||||||
672 | for (int i = 0; i < n; ++i) {
| 8244-62348 | ||||||||||||||||||
673 | const char *a = ucnv_getAlias(m_name, i, &error); | - | ||||||||||||||||||
674 | // skip the canonical name | - | ||||||||||||||||||
675 | if (!a || !qstrcmp(a, m_name))
| 0-62348 | ||||||||||||||||||
676 | continue; executed 8244 times by 5 tests: continue; Executed by:
| 8244 | ||||||||||||||||||
677 | aliases += a; | - | ||||||||||||||||||
678 | } executed 54104 times by 5 tests: end of block Executed by:
| 54104 | ||||||||||||||||||
679 | - | |||||||||||||||||||
680 | return aliases; executed 8244 times by 5 tests: return aliases; Executed by:
| 8244 | ||||||||||||||||||
681 | } | - | ||||||||||||||||||
682 | - | |||||||||||||||||||
683 | - | |||||||||||||||||||
684 | int QIcuCodec::mibEnum() const | - | ||||||||||||||||||
685 | { | - | ||||||||||||||||||
686 | for (int i = 0; i < mibToNameSize; ++i) {
| 335-437034 | ||||||||||||||||||
687 | if (qTextCodecNameMatch(m_name, (mibToNameTable + mibToName[i].index)))
| 5897-431137 | ||||||||||||||||||
688 | return mibToName[i].mib; executed 5897 times by 4 tests: return mibToName[i].mib; Executed by:
| 5897 | ||||||||||||||||||
689 | } executed 431137 times by 3 tests: end of block Executed by:
| 431137 | ||||||||||||||||||
690 | - | |||||||||||||||||||
691 | return 0; executed 335 times by 1 test: return 0; Executed by:
| 335 | ||||||||||||||||||
692 | } | - | ||||||||||||||||||
693 | - | |||||||||||||||||||
694 | QT_END_NAMESPACE | - | ||||||||||||||||||
695 | - | |||||||||||||||||||
696 | #endif // QT_NO_TEXTCODEC | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |