Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | enum { Endian = 0, Data = 1 }; | - |
5 | | - |
6 | QByteArray QUtf8::convertFromUnicode(const QChar *uc, int len, QTextCodec::ConverterState *state) | - |
7 | { | - |
8 | uchar replacement = '?'; | - |
9 | int rlen = 3*len; | - |
10 | int surrogate_high = -1; | - |
11 | if (state) { evaluated: state yes Evaluation Count:526492 | yes Evaluation Count:296270 |
| 296270-526492 |
12 | if (state->flags & QTextCodec::ConvertInvalidToNull) evaluated: state->flags & QTextCodec::ConvertInvalidToNull yes Evaluation Count:497380 | yes Evaluation Count:29112 |
| 29112-497380 |
13 | replacement = 0; executed: replacement = 0; Execution Count:497380 | 497380 |
14 | if (!(state->flags & QTextCodec::IgnoreHeader)) evaluated: !(state->flags & QTextCodec::IgnoreHeader) yes Evaluation Count:497633 | yes Evaluation Count:28859 |
| 28859-497633 |
15 | rlen += 3; executed: rlen += 3; Execution Count:497633 | 497633 |
16 | if (state->remainingChars) evaluated: state->remainingChars yes Evaluation Count:6 | yes Evaluation Count:526486 |
| 6-526486 |
17 | surrogate_high = state->state_data[0]; executed: surrogate_high = state->state_data[0]; Execution Count:6 | 6 |
18 | } executed: } Execution Count:526492 | 526492 |
19 | | - |
20 | QByteArray rstr; | - |
21 | rstr.resize(rlen); | - |
22 | uchar* cursor = (uchar*)rstr.data(); | - |
23 | const QChar *ch = uc; | - |
24 | int invalid = 0; | - |
25 | if (state && !(state->flags & QTextCodec::IgnoreHeader)) { evaluated: state yes Evaluation Count:526492 | yes Evaluation Count:296269 |
evaluated: !(state->flags & QTextCodec::IgnoreHeader) yes Evaluation Count:497633 | yes Evaluation Count:28859 |
| 28859-526492 |
26 | *cursor++ = 0xef; | - |
27 | *cursor++ = 0xbb; | - |
28 | *cursor++ = 0xbf; | - |
29 | } executed: } Execution Count:497633 | 497633 |
30 | | - |
31 | const QChar *end = ch + len; | - |
32 | while (ch < end) { evaluated: ch < end yes Evaluation Count:26531872 | yes Evaluation Count:822763 |
| 822763-26531872 |
33 | uint u = ch->unicode(); | - |
34 | if (surrogate_high >= 0) { evaluated: surrogate_high >= 0 yes Evaluation Count:186 | yes Evaluation Count:26531675 |
| 186-26531675 |
35 | if (ch->isLowSurrogate()) { partially evaluated: ch->isLowSurrogate() yes Evaluation Count:186 | no Evaluation Count:0 |
| 0-186 |
36 | u = QChar::surrogateToUcs4(surrogate_high, u); | - |
37 | surrogate_high = -1; | - |
38 | } else { executed: } Execution Count:186 | 186 |
39 | | - |
40 | *cursor = replacement; | - |
41 | ++ch; | - |
42 | ++invalid; | - |
43 | surrogate_high = -1; | - |
44 | continue; never executed: continue; | 0 |
45 | } | - |
46 | } else if (ch->isLowSurrogate()) { partially evaluated: ch->isLowSurrogate() no Evaluation Count:0 | yes Evaluation Count:26531688 |
| 0-26531688 |
47 | | - |
48 | *cursor = replacement; | - |
49 | ++ch; | - |
50 | ++invalid; | - |
51 | continue; never executed: continue; | 0 |
52 | } else if (ch->isHighSurrogate()) { evaluated: ch->isHighSurrogate() yes Evaluation Count:186 | yes Evaluation Count:26531499 |
| 186-26531499 |
53 | surrogate_high = u; | - |
54 | ++ch; | - |
55 | continue; executed: continue; Execution Count:186 | 186 |
56 | } | - |
57 | | - |
58 | if (u < 0x80) { evaluated: u < 0x80 yes Evaluation Count:26116723 | yes Evaluation Count:414970 |
| 414970-26116723 |
59 | *cursor++ = (uchar)u; | - |
60 | } else { executed: } Execution Count:26116720 | 26116720 |
61 | if (u < 0x0800) { evaluated: u < 0x0800 yes Evaluation Count:5209 | yes Evaluation Count:409761 |
| 5209-409761 |
62 | *cursor++ = 0xc0 | ((uchar) (u >> 6)); | - |
63 | } else { executed: } Execution Count:5209 | 5209 |
64 | | - |
65 | if (QChar::isNonCharacter(u)) { evaluated: QChar::isNonCharacter(u) yes Evaluation Count:233 | yes Evaluation Count:409528 |
| 233-409528 |
66 | *cursor++ = replacement; | - |
67 | ++ch; | - |
68 | ++invalid; | - |
69 | continue; executed: continue; Execution Count:233 | 233 |
70 | } | - |
71 | | - |
72 | if (QChar::requiresSurrogates(u)) { evaluated: QChar::requiresSurrogates(u) yes Evaluation Count:58 | yes Evaluation Count:409470 |
| 58-409470 |
73 | *cursor++ = 0xf0 | ((uchar) (u >> 18)); | - |
74 | *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f); | - |
75 | } else { executed: } Execution Count:58 | 58 |
76 | *cursor++ = 0xe0 | (((uchar) (u >> 12)) & 0x3f); | - |
77 | } executed: } Execution Count:409470 | 409470 |
78 | *cursor++ = 0x80 | (((uchar) (u >> 6)) & 0x3f); | - |
79 | } executed: } Execution Count:409528 | 409528 |
80 | *cursor++ = 0x80 | ((uchar) (u&0x3f)); | - |
81 | } executed: } Execution Count:414737 | 414737 |
82 | ++ch; | - |
83 | } executed: } Execution Count:26531459 | 26531459 |
84 | | - |
85 | rstr.resize(cursor - (const uchar*)rstr.constData()); | - |
86 | if (state) { evaluated: state yes Evaluation Count:526492 | yes Evaluation Count:296275 |
| 296275-526492 |
87 | state->invalidChars += invalid; | - |
88 | state->flags |= QTextCodec::IgnoreHeader; | - |
89 | state->remainingChars = 0; | - |
90 | if (surrogate_high >= 0) { evaluated: surrogate_high >= 0 yes Evaluation Count:6 | yes Evaluation Count:526486 |
| 6-526486 |
91 | state->remainingChars = 1; | - |
92 | state->state_data[0] = surrogate_high; | - |
93 | } executed: } Execution Count:6 | 6 |
94 | } executed: } Execution Count:526492 | 526492 |
95 | return rstr; executed: return rstr; Execution Count:822767 | 822767 |
96 | } | - |
97 | | - |
98 | QString QUtf8::convertToUnicode(const char *chars, int len, QTextCodec::ConverterState *state) | - |
99 | { | - |
100 | bool headerdone = false; | - |
101 | ushort replacement = QChar::ReplacementCharacter; | - |
102 | int need = 0; | - |
103 | int error = -1; | - |
104 | uint uc = 0; | - |
105 | uint min_uc = 0; | - |
106 | if (state) { evaluated: state yes Evaluation Count:41144773 | yes Evaluation Count:20727340 |
| 20727340-41144773 |
107 | if (state->flags & QTextCodec::IgnoreHeader) evaluated: state->flags & QTextCodec::IgnoreHeader yes Evaluation Count:41135273 | yes Evaluation Count:9500 |
| 9500-41135273 |
108 | headerdone = true; executed: headerdone = true; Execution Count:41135273 | 41135273 |
109 | if (state->flags & QTextCodec::ConvertInvalidToNull) evaluated: state->flags & QTextCodec::ConvertInvalidToNull yes Evaluation Count:4 | yes Evaluation Count:41144769 |
| 4-41144769 |
110 | replacement = QChar::Null; executed: replacement = QChar::Null; Execution Count:4 | 4 |
111 | need = state->remainingChars; | - |
112 | if (need) { evaluated: need yes Evaluation Count:671 | yes Evaluation Count:41144102 |
| 671-41144102 |
113 | uc = state->state_data[0]; | - |
114 | min_uc = state->state_data[1]; | - |
115 | } executed: } Execution Count:671 | 671 |
116 | } executed: } Execution Count:41144773 | 41144773 |
117 | if (!headerdone && len > 3 evaluated: !headerdone yes Evaluation Count:20736843 | yes Evaluation Count:41135273 |
evaluated: len > 3 yes Evaluation Count:5241607 | yes Evaluation Count:15495250 |
| 5241607-41135273 |
118 | && (uchar)chars[0] == 0xef && (uchar)chars[1] == 0xbb && (uchar)chars[2] == 0xbf) { evaluated: (uchar)chars[0] == 0xef yes Evaluation Count:15 | yes Evaluation Count:5241613 |
partially evaluated: (uchar)chars[1] == 0xbb yes Evaluation Count:15 | no Evaluation Count:0 |
partially evaluated: (uchar)chars[2] == 0xbf yes Evaluation Count:15 | no Evaluation Count:0 |
| 0-5241613 |
119 | | - |
120 | chars += 3; | - |
121 | len -= 3; | - |
122 | headerdone = true; | - |
123 | } executed: } Execution Count:15 | 15 |
124 | | - |
125 | QString result(need + len + 1, Qt::Uninitialized); | - |
126 | ushort *qch = (ushort *)result.unicode(); | - |
127 | uchar ch; | - |
128 | int invalid = 0; | - |
129 | | - |
130 | for (int i = 0; i < len; ++i) { evaluated: i < len yes Evaluation Count:145837819 | yes Evaluation Count:61872075 |
| 61872075-145837819 |
131 | ch = chars[i]; | - |
132 | if (need) { evaluated: need yes Evaluation Count:279039 | yes Evaluation Count:145558840 |
| 279039-145558840 |
133 | if ((ch&0xc0) == 0x80) { evaluated: (ch&0xc0) == 0x80 yes Evaluation Count:277529 | yes Evaluation Count:1510 |
| 1510-277529 |
134 | uc = (uc << 6) | (ch & 0x3f); | - |
135 | --need; | - |
136 | if (!need) { evaluated: !need yes Evaluation Count:141211 | yes Evaluation Count:136318 |
| 136318-141211 |
137 | | - |
138 | bool nonCharacter; | - |
139 | if (!headerdone && uc == 0xfeff) { evaluated: !headerdone yes Evaluation Count:304 | yes Evaluation Count:140907 |
evaluated: uc == 0xfeff yes Evaluation Count:8 | yes Evaluation Count:296 |
| 8-140907 |
140 | | - |
141 | } else if (!(nonCharacter = QChar::isNonCharacter(uc)) && QChar::requiresSurrogates(uc) && uc <= QChar::LastValidCodePoint) { evaluated: !(nonCharacter = QChar::isNonCharacter(uc)) yes Evaluation Count:140937 | yes Evaluation Count:266 |
evaluated: QChar::requiresSurrogates(uc) yes Evaluation Count:175 | yes Evaluation Count:140762 |
evaluated: uc <= QChar::LastValidCodePoint yes Evaluation Count:163 | yes Evaluation Count:12 |
executed: } Execution Count:8 | 8-140937 |
142 | | - |
143 | qt_noop(); | - |
144 | *qch++ = QChar::highSurrogate(uc); | - |
145 | *qch++ = QChar::lowSurrogate(uc); | - |
146 | } else if ((uc < min_uc) || QChar::isSurrogate(uc) || nonCharacter || uc > QChar::LastValidCodePoint) { evaluated: (uc < min_uc) yes Evaluation Count:49 | yes Evaluation Count:140991 |
evaluated: QChar::isSurrogate(uc) yes Evaluation Count:67 | yes Evaluation Count:140924 |
evaluated: nonCharacter yes Evaluation Count:264 | yes Evaluation Count:140660 |
evaluated: uc > QChar::LastValidCodePoint yes Evaluation Count:12 | yes Evaluation Count:140648 |
executed: } Execution Count:163 | 12-140991 |
147 | | - |
148 | *qch++ = replacement; | - |
149 | ++invalid; | - |
150 | } else { executed: } Execution Count:392 | 392 |
151 | *qch++ = uc; | - |
152 | } executed: } Execution Count:140648 | 140648 |
153 | headerdone = true; | - |
154 | } executed: } Execution Count:141211 | 141211 |
155 | } else { executed: } Execution Count:277529 | 277529 |
156 | | - |
157 | i = error; | - |
158 | *qch++ = replacement; | - |
159 | ++invalid; | - |
160 | need = 0; | - |
161 | headerdone = true; | - |
162 | } executed: } Execution Count:1510 | 1510 |
163 | } else { | - |
164 | if (ch < 128) { evaluated: ch < 128 yes Evaluation Count:145413700 | yes Evaluation Count:145111 |
| 145111-145413700 |
165 | *qch++ = ushort(ch); | - |
166 | headerdone = true; | - |
167 | } else if ((ch & 0xe0) == 0xc0) { evaluated: (ch & 0xe0) == 0xc0 yes Evaluation Count:6514 | yes Evaluation Count:138597 |
executed: } Execution Count:145413886 | 6514-145413886 |
168 | uc = ch & 0x1f; | - |
169 | need = 1; | - |
170 | error = i; | - |
171 | min_uc = 0x80; | - |
172 | headerdone = true; | - |
173 | } else if ((ch & 0xf0) == 0xe0) { evaluated: (ch & 0xf0) == 0xe0 yes Evaluation Count:135754 | yes Evaluation Count:2843 |
executed: } Execution Count:6514 | 2843-135754 |
174 | uc = ch & 0x0f; | - |
175 | need = 2; | - |
176 | error = i; | - |
177 | min_uc = 0x800; | - |
178 | } else if ((ch&0xf8) == 0xf0) { evaluated: (ch&0xf8) == 0xf0 yes Evaluation Count:497 | yes Evaluation Count:2346 |
executed: } Execution Count:135754 | 497-135754 |
179 | uc = ch & 0x07; | - |
180 | need = 3; | - |
181 | error = i; | - |
182 | min_uc = 0x10000; | - |
183 | headerdone = true; | - |
184 | } else { executed: } Execution Count:497 | 497 |
185 | | - |
186 | *qch++ = replacement; | - |
187 | ++invalid; | - |
188 | headerdone = true; | - |
189 | } executed: } Execution Count:2346 | 2346 |
190 | } | - |
191 | } | - |
192 | if (!state && need > 0) { evaluated: !state yes Evaluation Count:20727302 | yes Evaluation Count:41144773 |
evaluated: need > 0 yes Evaluation Count:27 | yes Evaluation Count:20727253 |
| 27-41144773 |
193 | | - |
194 | for (int i = error; i < len; ++i) { evaluated: i < len yes Evaluation Count:43 | yes Evaluation Count:27 |
| 27-43 |
195 | *qch++ = replacement; | - |
196 | ++invalid; | - |
197 | } executed: } Execution Count:43 | 43 |
198 | } executed: } Execution Count:27 | 27 |
199 | result.truncate(qch - (ushort *)result.unicode()); | - |
200 | if (state) { evaluated: state yes Evaluation Count:41144773 | yes Evaluation Count:20727290 |
| 20727290-41144773 |
201 | state->invalidChars += invalid; | - |
202 | state->remainingChars = need; | - |
203 | if (headerdone) evaluated: headerdone yes Evaluation Count:41144749 | yes Evaluation Count:24 |
| 24-41144749 |
204 | state->flags |= QTextCodec::IgnoreHeader; executed: state->flags |= QTextCodec::IgnoreHeader; Execution Count:41144749 | 41144749 |
205 | state->state_data[0] = need ? uc : 0; evaluated: need yes Evaluation Count:688 | yes Evaluation Count:41144085 |
| 688-41144085 |
206 | state->state_data[1] = need ? min_uc : 0; evaluated: need yes Evaluation Count:688 | yes Evaluation Count:41144085 |
| 688-41144085 |
207 | } executed: } Execution Count:41144773 | 41144773 |
208 | return result; executed: return result; Execution Count:61872069 | 61872069 |
209 | } | - |
210 | | - |
211 | QByteArray QUtf16::convertFromUnicode(const QChar *uc, int len, QTextCodec::ConverterState *state, DataEndianness e) | - |
212 | { | - |
213 | DataEndianness endian = e; | - |
214 | int length = 2*len; | - |
215 | if (!state || (!(state->flags & QTextCodec::IgnoreHeader))) { evaluated: !state yes Evaluation Count:52 | yes Evaluation Count:257121 |
evaluated: (!(state->flags & QTextCodec::IgnoreHeader)) yes Evaluation Count:248388 | yes Evaluation Count:8733 |
| 52-257121 |
216 | length += 2; | - |
217 | } executed: } Execution Count:248440 | 248440 |
218 | if (e == DetectEndianness) { evaluated: e == DetectEndianness yes Evaluation Count:85717 | yes Evaluation Count:171456 |
| 85717-171456 |
219 | endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; partially evaluated: (QSysInfo::ByteOrder == QSysInfo::BigEndian) no Evaluation Count:0 | yes Evaluation Count:85717 |
| 0-85717 |
220 | } executed: } Execution Count:85717 | 85717 |
221 | | - |
222 | QByteArray d; | - |
223 | d.resize(length); | - |
224 | char *data = d.data(); | - |
225 | if (!state || !(state->flags & QTextCodec::IgnoreHeader)) { evaluated: !state yes Evaluation Count:52 | yes Evaluation Count:257121 |
evaluated: !(state->flags & QTextCodec::IgnoreHeader) yes Evaluation Count:248388 | yes Evaluation Count:8733 |
| 52-257121 |
226 | QChar bom(QChar::ByteOrderMark); | - |
227 | if (endian == BigEndianness) { evaluated: endian == BigEndianness yes Evaluation Count:82818 | yes Evaluation Count:165622 |
| 82818-165622 |
228 | data[0] = bom.row(); | - |
229 | data[1] = bom.cell(); | - |
230 | } else { executed: } Execution Count:82818 | 82818 |
231 | data[0] = bom.cell(); | - |
232 | data[1] = bom.row(); | - |
233 | } executed: } Execution Count:165622 | 165622 |
234 | data += 2; | - |
235 | } executed: } Execution Count:248440 | 248440 |
236 | if (endian == BigEndianness) { evaluated: endian == BigEndianness yes Evaluation Count:85725 | yes Evaluation Count:171448 |
| 85725-171448 |
237 | for (int i = 0; i < len; ++i) { evaluated: i < len yes Evaluation Count:255542 | yes Evaluation Count:85725 |
| 85725-255542 |
238 | *(data++) = uc[i].row(); | - |
239 | *(data++) = uc[i].cell(); | - |
240 | } executed: } Execution Count:255542 | 255542 |
241 | } else { executed: } Execution Count:85725 | 85725 |
242 | for (int i = 0; i < len; ++i) { evaluated: i < len yes Evaluation Count:510988 | yes Evaluation Count:171448 |
| 171448-510988 |
243 | *(data++) = uc[i].cell(); | - |
244 | *(data++) = uc[i].row(); | - |
245 | } executed: } Execution Count:510988 | 510988 |
246 | } executed: } Execution Count:171448 | 171448 |
247 | | - |
248 | if (state) { evaluated: state yes Evaluation Count:257121 | yes Evaluation Count:52 |
| 52-257121 |
249 | state->remainingChars = 0; | - |
250 | state->flags |= QTextCodec::IgnoreHeader; | - |
251 | } executed: } Execution Count:257121 | 257121 |
252 | return d; executed: return d; Execution Count:257173 | 257173 |
253 | } | - |
254 | | - |
255 | QString QUtf16::convertToUnicode(const char *chars, int len, QTextCodec::ConverterState *state, DataEndianness e) | - |
256 | { | - |
257 | DataEndianness endian = e; | - |
258 | bool half = false; | - |
259 | uchar buf = 0; | - |
260 | bool headerdone = false; | - |
261 | if (state) { evaluated: state yes Evaluation Count:4645 | yes Evaluation Count:186 |
| 186-4645 |
262 | headerdone = state->flags & QTextCodec::IgnoreHeader; | - |
263 | if (endian == DetectEndianness) evaluated: endian == DetectEndianness yes Evaluation Count:3128 | yes Evaluation Count:1517 |
| 1517-3128 |
264 | endian = (DataEndianness)state->state_data[Endian]; executed: endian = (DataEndianness)state->state_data[Endian]; Execution Count:3128 | 3128 |
265 | if (state->remainingChars) { evaluated: state->remainingChars yes Evaluation Count:651 | yes Evaluation Count:3994 |
| 651-3994 |
266 | half = true; | - |
267 | buf = state->state_data[Data]; | - |
268 | } executed: } Execution Count:651 | 651 |
269 | } executed: } Execution Count:4645 | 4645 |
270 | if (headerdone && endian == DetectEndianness) evaluated: headerdone yes Evaluation Count:4262 | yes Evaluation Count:569 |
evaluated: endian == DetectEndianness yes Evaluation Count:1 | yes Evaluation Count:4261 |
| 1-4262 |
271 | endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; partially evaluated: (QSysInfo::ByteOrder == QSysInfo::BigEndian) no Evaluation Count:0 | yes Evaluation Count:1 |
executed: endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; Execution Count:1 | 0-1 |
272 | | - |
273 | QString result(len, Qt::Uninitialized); | - |
274 | QChar *qch = (QChar *)result.unicode(); | - |
275 | while (len--) { evaluated: len-- yes Evaluation Count:2107581 | yes Evaluation Count:4831 |
| 4831-2107581 |
276 | if (half) { evaluated: half yes Evaluation Count:1053790 | yes Evaluation Count:1053791 |
| 1053790-1053791 |
277 | QChar ch; | - |
278 | if (endian == LittleEndianness) { evaluated: endian == LittleEndianness yes Evaluation Count:702655 | yes Evaluation Count:351135 |
| 351135-702655 |
279 | ch.setRow(*chars++); | - |
280 | ch.setCell(buf); | - |
281 | } else { executed: } Execution Count:702655 | 702655 |
282 | ch.setRow(buf); | - |
283 | ch.setCell(*chars++); | - |
284 | } executed: } Execution Count:351135 | 351135 |
285 | if (!headerdone) { evaluated: !headerdone yes Evaluation Count:511 | yes Evaluation Count:1053279 |
| 511-1053279 |
286 | headerdone = true; | - |
287 | if (endian == DetectEndianness) { evaluated: endian == DetectEndianness yes Evaluation Count:213 | yes Evaluation Count:298 |
| 213-298 |
288 | if (ch == QChar::ByteOrderSwapped) { evaluated: ch == QChar::ByteOrderSwapped yes Evaluation Count:80 | yes Evaluation Count:133 |
| 80-133 |
289 | endian = LittleEndianness; | - |
290 | } else if (ch == QChar::ByteOrderMark) { evaluated: ch == QChar::ByteOrderMark yes Evaluation Count:5 | yes Evaluation Count:128 |
executed: } Execution Count:80 | 5-128 |
291 | endian = BigEndianness; | - |
292 | } else { executed: } Execution Count:5 | 5 |
293 | if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { partially evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian no Evaluation Count:0 | yes Evaluation Count:128 |
| 0-128 |
294 | endian = BigEndianness; | - |
295 | } else { | 0 |
296 | endian = LittleEndianness; | - |
297 | ch = QChar((ch.unicode() >> 8) | ((ch.unicode() & 0xff) << 8)); | - |
298 | } executed: } Execution Count:128 | 128 |
299 | *qch++ = ch; | - |
300 | } executed: } Execution Count:128 | 128 |
301 | } else if (ch != QChar::ByteOrderMark) { evaluated: ch != QChar::ByteOrderMark yes Evaluation Count:54 | yes Evaluation Count:244 |
| 54-244 |
302 | *qch++ = ch; | - |
303 | } executed: } Execution Count:54 | 54 |
304 | } else { | - |
305 | *qch++ = ch; | - |
306 | } executed: } Execution Count:1053279 | 1053279 |
307 | half = false; | - |
308 | } else { executed: } Execution Count:1053790 | 1053790 |
309 | buf = *chars++; | - |
310 | half = true; | - |
311 | } executed: } Execution Count:1053791 | 1053791 |
312 | } | - |
313 | result.truncate(qch - result.unicode()); | - |
314 | | - |
315 | if (state) { evaluated: state yes Evaluation Count:4645 | yes Evaluation Count:186 |
| 186-4645 |
316 | if (headerdone) evaluated: headerdone yes Evaluation Count:4587 | yes Evaluation Count:58 |
| 58-4587 |
317 | state->flags |= QTextCodec::IgnoreHeader; executed: state->flags |= QTextCodec::IgnoreHeader; Execution Count:4587 | 4587 |
318 | state->state_data[Endian] = endian; | - |
319 | if (half) { evaluated: half yes Evaluation Count:652 | yes Evaluation Count:3993 |
| 652-3993 |
320 | state->remainingChars = 1; | - |
321 | state->state_data[Data] = buf; | - |
322 | } else { executed: } Execution Count:652 | 652 |
323 | state->remainingChars = 0; | - |
324 | state->state_data[Data] = 0; | - |
325 | } executed: } Execution Count:3993 | 3993 |
326 | } | - |
327 | return result; executed: return result; Execution Count:4831 | 4831 |
328 | } | - |
329 | | - |
330 | QByteArray QUtf32::convertFromUnicode(const QChar *uc, int len, QTextCodec::ConverterState *state, DataEndianness e) | - |
331 | { | - |
332 | DataEndianness endian = e; | - |
333 | int length = 4*len; | - |
334 | if (!state || (!(state->flags & QTextCodec::IgnoreHeader))) { evaluated: !state yes Evaluation Count:22 | yes Evaluation Count:85706 |
evaluated: (!(state->flags & QTextCodec::IgnoreHeader)) yes Evaluation Count:82797 | yes Evaluation Count:2909 |
| 22-85706 |
335 | length += 4; | - |
336 | } executed: } Execution Count:82819 | 82819 |
337 | if (e == DetectEndianness) { evaluated: e == DetectEndianness yes Evaluation Count:85713 | yes Evaluation Count:15 |
| 15-85713 |
338 | endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; partially evaluated: (QSysInfo::ByteOrder == QSysInfo::BigEndian) no Evaluation Count:0 | yes Evaluation Count:85713 |
| 0-85713 |
339 | } executed: } Execution Count:85713 | 85713 |
340 | | - |
341 | QByteArray d(length, Qt::Uninitialized); | - |
342 | char *data = d.data(); | - |
343 | if (!state || !(state->flags & QTextCodec::IgnoreHeader)) { evaluated: !state yes Evaluation Count:22 | yes Evaluation Count:85706 |
evaluated: !(state->flags & QTextCodec::IgnoreHeader) yes Evaluation Count:82797 | yes Evaluation Count:2909 |
| 22-85706 |
344 | if (endian == BigEndianness) { evaluated: endian == BigEndianness yes Evaluation Count:7 | yes Evaluation Count:82812 |
| 7-82812 |
345 | data[0] = 0; | - |
346 | data[1] = 0; | - |
347 | data[2] = (char)0xfe; | - |
348 | data[3] = (char)0xff; | - |
349 | } else { executed: } Execution Count:7 | 7 |
350 | data[0] = (char)0xff; | - |
351 | data[1] = (char)0xfe; | - |
352 | data[2] = 0; | - |
353 | data[3] = 0; | - |
354 | } executed: } Execution Count:82812 | 82812 |
355 | data += 4; | - |
356 | } executed: } Execution Count:82819 | 82819 |
357 | if (endian == BigEndianness) { evaluated: endian == BigEndianness yes Evaluation Count:7 | yes Evaluation Count:85721 |
| 7-85721 |
358 | for (int i = 0; i < len; ++i) { evaluated: i < len yes Evaluation Count:54 | yes Evaluation Count:7 |
| 7-54 |
359 | uint cp = uc[i].unicode(); | - |
360 | if (uc[i].isHighSurrogate() && i < len - 1) partially evaluated: uc[i].isHighSurrogate() no Evaluation Count:0 | yes Evaluation Count:54 |
never evaluated: i < len - 1 | 0-54 |
361 | cp = QChar::surrogateToUcs4(cp, uc[++i].unicode()); never executed: cp = QChar::surrogateToUcs4(cp, uc[++i].unicode()); | 0 |
362 | *(data++) = cp >> 24; | - |
363 | *(data++) = (cp >> 16) & 0xff; | - |
364 | *(data++) = (cp >> 8) & 0xff; | - |
365 | *(data++) = cp & 0xff; | - |
366 | } executed: } Execution Count:54 | 54 |
367 | } else { executed: } Execution Count:7 | 7 |
368 | for (int i = 0; i < len; ++i) { evaluated: i < len yes Evaluation Count:255438 | yes Evaluation Count:85721 |
| 85721-255438 |
369 | uint cp = uc[i].unicode(); | - |
370 | if (uc[i].isHighSurrogate() && i < len - 1) partially evaluated: uc[i].isHighSurrogate() no Evaluation Count:0 | yes Evaluation Count:255438 |
never evaluated: i < len - 1 | 0-255438 |
371 | cp = QChar::surrogateToUcs4(cp, uc[++i].unicode()); never executed: cp = QChar::surrogateToUcs4(cp, uc[++i].unicode()); | 0 |
372 | *(data++) = cp & 0xff; | - |
373 | *(data++) = (cp >> 8) & 0xff; | - |
374 | *(data++) = (cp >> 16) & 0xff; | - |
375 | *(data++) = cp >> 24; | - |
376 | } executed: } Execution Count:255438 | 255438 |
377 | } executed: } Execution Count:85721 | 85721 |
378 | | - |
379 | if (state) { evaluated: state yes Evaluation Count:85706 | yes Evaluation Count:22 |
| 22-85706 |
380 | state->remainingChars = 0; | - |
381 | state->flags |= QTextCodec::IgnoreHeader; | - |
382 | } executed: } Execution Count:85706 | 85706 |
383 | return d; executed: return d; Execution Count:85728 | 85728 |
384 | } | - |
385 | | - |
386 | QString QUtf32::convertToUnicode(const char *chars, int len, QTextCodec::ConverterState *state, DataEndianness e) | - |
387 | { | - |
388 | DataEndianness endian = e; | - |
389 | uchar tuple[4]; | - |
390 | int num = 0; | - |
391 | bool headerdone = false; | - |
392 | if (state) { evaluated: state yes Evaluation Count:1065 | yes Evaluation Count:49 |
| 49-1065 |
393 | headerdone = state->flags & QTextCodec::IgnoreHeader; | - |
394 | if (endian == DetectEndianness) { evaluated: endian == DetectEndianness yes Evaluation Count:695 | yes Evaluation Count:370 |
| 370-695 |
395 | endian = (DataEndianness)state->state_data[Endian]; | - |
396 | } executed: } Execution Count:695 | 695 |
397 | num = state->remainingChars; | - |
398 | memcpy(tuple, &state->state_data[Data], 4); | - |
399 | } executed: } Execution Count:1065 | 1065 |
400 | if (headerdone && endian == DetectEndianness) evaluated: headerdone yes Evaluation Count:3 | yes Evaluation Count:1111 |
evaluated: endian == DetectEndianness yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-1111 |
401 | endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; partially evaluated: (QSysInfo::ByteOrder == QSysInfo::BigEndian) no Evaluation Count:0 | yes Evaluation Count:1 |
executed: endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; Execution Count:1 | 0-1 |
402 | | - |
403 | QString result; | - |
404 | result.resize((num + len) >> 2 << 1); | - |
405 | QChar *qch = (QChar *)result.unicode(); | - |
406 | | - |
407 | const char *end = chars + len; | - |
408 | while (chars < end) { evaluated: chars < end yes Evaluation Count:1390772 | yes Evaluation Count:1114 |
| 1114-1390772 |
409 | tuple[num++] = *chars++; | - |
410 | if (num == 4) { evaluated: num == 4 yes Evaluation Count:347693 | yes Evaluation Count:1043079 |
| 347693-1043079 |
411 | if (!headerdone) { evaluated: !headerdone yes Evaluation Count:347681 | yes Evaluation Count:12 |
| 12-347681 |
412 | if (endian == DetectEndianness) { evaluated: endian == DetectEndianness yes Evaluation Count:51 | yes Evaluation Count:347630 |
| 51-347630 |
413 | if (tuple[0] == 0xff && tuple[1] == 0xfe && tuple[2] == 0 && tuple[3] == 0 && endian != BigEndianness) { evaluated: tuple[0] == 0xff yes Evaluation Count:9 | yes Evaluation Count:42 |
partially evaluated: tuple[1] == 0xfe yes Evaluation Count:9 | no Evaluation Count:0 |
partially evaluated: tuple[2] == 0 yes Evaluation Count:9 | no Evaluation Count:0 |
partially evaluated: tuple[3] == 0 yes Evaluation Count:9 | no Evaluation Count:0 |
partially evaluated: endian != BigEndianness yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-42 |
414 | endian = LittleEndianness; | - |
415 | num = 0; | - |
416 | continue; executed: continue; Execution Count:9 | 9 |
417 | } else if (tuple[0] == 0 && tuple[1] == 0 && tuple[2] == 0xfe && tuple[3] == 0xff && endian != LittleEndianness) { evaluated: tuple[0] == 0 yes Evaluation Count:7 | yes Evaluation Count:35 |
partially evaluated: tuple[1] == 0 yes Evaluation Count:7 | no Evaluation Count:0 |
evaluated: tuple[2] == 0xfe yes Evaluation Count:1 | yes Evaluation Count:6 |
partially evaluated: tuple[3] == 0xff yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: endian != LittleEndianness yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-35 |
418 | endian = BigEndianness; | - |
419 | num = 0; | - |
420 | continue; executed: continue; Execution Count:1 | 1 |
421 | } else if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { partially evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian no Evaluation Count:0 | yes Evaluation Count:41 |
| 0-41 |
422 | endian = BigEndianness; | - |
423 | } else { | 0 |
424 | endian = LittleEndianness; | - |
425 | } executed: } Execution Count:41 | 41 |
426 | } else if (((endian == BigEndianness) ? qFromBigEndian<quint32>(tuple) : qFromLittleEndian<quint32>(tuple)) == QChar::ByteOrderMark) { evaluated: ((endian == BigEndianness) ? qFromBigEndian<quint32>(tuple) : qFromLittleEndian<quint32>(tuple)) == QChar::ByteOrderMark yes Evaluation Count:47 | yes Evaluation Count:347583 |
evaluated: (endian == BigEndianness) yes Evaluation Count:220 | yes Evaluation Count:347410 |
| 47-347583 |
427 | num = 0; | - |
428 | continue; executed: continue; Execution Count:47 | 47 |
429 | } | - |
430 | } | - |
431 | uint code = (endian == BigEndianness) ? qFromBigEndian<quint32>(tuple) : qFromLittleEndian<quint32>(tuple); evaluated: (endian == BigEndianness) yes Evaluation Count:200 | yes Evaluation Count:347436 |
| 200-347436 |
432 | if (QChar::requiresSurrogates(code)) { evaluated: QChar::requiresSurrogates(code) yes Evaluation Count:19 | yes Evaluation Count:347617 |
| 19-347617 |
433 | *qch++ = QChar::highSurrogate(code); | - |
434 | *qch++ = QChar::lowSurrogate(code); | - |
435 | } else { executed: } Execution Count:19 | 19 |
436 | *qch++ = code; | - |
437 | } executed: } Execution Count:347617 | 347617 |
438 | num = 0; | - |
439 | } executed: } Execution Count:347636 | 347636 |
440 | } executed: } Execution Count:1390715 | 1390715 |
441 | result.truncate(qch - result.unicode()); | - |
442 | | - |
443 | if (state) { evaluated: state yes Evaluation Count:1065 | yes Evaluation Count:49 |
| 49-1065 |
444 | if (headerdone) evaluated: headerdone yes Evaluation Count:3 | yes Evaluation Count:1062 |
| 3-1062 |
445 | state->flags |= QTextCodec::IgnoreHeader; executed: state->flags |= QTextCodec::IgnoreHeader; Execution Count:3 | 3 |
446 | state->state_data[Endian] = endian; | - |
447 | state->remainingChars = num; | - |
448 | memcpy(&state->state_data[Data], tuple, 4); | - |
449 | } executed: } Execution Count:1065 | 1065 |
450 | return result; executed: return result; Execution Count:1114 | 1114 |
451 | } | - |
452 | | - |
453 | | - |
454 | | - |
455 | | - |
456 | QUtf8Codec::~QUtf8Codec() | - |
457 | { | - |
458 | } | - |
459 | | - |
460 | QByteArray QUtf8Codec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const | - |
461 | { | - |
462 | return QUtf8::convertFromUnicode(uc, len, state); executed: return QUtf8::convertFromUnicode(uc, len, state); Execution Count:797595 | 797595 |
463 | } | - |
464 | | - |
465 | void QUtf8Codec::convertToUnicode(QString *target, const char *chars, int len, ConverterState *state) const | - |
466 | { | - |
467 | *target += QUtf8::convertToUnicode(chars, len, state); | - |
468 | } executed: } Execution Count:59082 | 59082 |
469 | | - |
470 | QString QUtf8Codec::convertToUnicode(const char *chars, int len, ConverterState *state) const | - |
471 | { | - |
472 | return QUtf8::convertToUnicode(chars, len, state); executed: return QUtf8::convertToUnicode(chars, len, state); Execution Count:41267178 | 41267178 |
473 | } | - |
474 | | - |
475 | QByteArray QUtf8Codec::name() const | - |
476 | { | - |
477 | return "UTF-8"; executed: return "UTF-8"; Execution Count:227 | 227 |
478 | } | - |
479 | | - |
480 | int QUtf8Codec::mibEnum() const | - |
481 | { | - |
482 | return 106; executed: return 106; Execution Count:59208 | 59208 |
483 | } | - |
484 | | - |
485 | QUtf16Codec::~QUtf16Codec() | - |
486 | { | - |
487 | } | - |
488 | | - |
489 | QByteArray QUtf16Codec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const | - |
490 | { | - |
491 | return QUtf16::convertFromUnicode(uc, len, state, e); executed: return QUtf16::convertFromUnicode(uc, len, state, e); Execution Count:257173 | 257173 |
492 | } | - |
493 | | - |
494 | QString QUtf16Codec::convertToUnicode(const char *chars, int len, ConverterState *state) const | - |
495 | { | - |
496 | return QUtf16::convertToUnicode(chars, len, state, e); executed: return QUtf16::convertToUnicode(chars, len, state, e); Execution Count:4725 | 4725 |
497 | } | - |
498 | | - |
499 | int QUtf16Codec::mibEnum() const | - |
500 | { | - |
501 | return 1015; executed: return 1015; Execution Count:458 | 458 |
502 | } | - |
503 | | - |
504 | QByteArray QUtf16Codec::name() const | - |
505 | { | - |
506 | return "UTF-16"; executed: return "UTF-16"; Execution Count:153 | 153 |
507 | } | - |
508 | | - |
509 | QList<QByteArray> QUtf16Codec::aliases() const | - |
510 | { | - |
511 | return QList<QByteArray>(); executed: return QList<QByteArray>(); Execution Count:140 | 140 |
512 | } | - |
513 | | - |
514 | int QUtf16BECodec::mibEnum() const | - |
515 | { | - |
516 | return 1013; executed: return 1013; Execution Count:35 | 35 |
517 | } | - |
518 | | - |
519 | QByteArray QUtf16BECodec::name() const | - |
520 | { | - |
521 | return "UTF-16BE"; executed: return "UTF-16BE"; Execution Count:166 | 166 |
522 | } | - |
523 | | - |
524 | QList<QByteArray> QUtf16BECodec::aliases() const | - |
525 | { | - |
526 | QList<QByteArray> list; | - |
527 | return list; executed: return list; Execution Count:154 | 154 |
528 | } | - |
529 | | - |
530 | int QUtf16LECodec::mibEnum() const | - |
531 | { | - |
532 | return 1014; executed: return 1014; Execution Count:33 | 33 |
533 | } | - |
534 | | - |
535 | QByteArray QUtf16LECodec::name() const | - |
536 | { | - |
537 | return "UTF-16LE"; executed: return "UTF-16LE"; Execution Count:161 | 161 |
538 | } | - |
539 | | - |
540 | QList<QByteArray> QUtf16LECodec::aliases() const | - |
541 | { | - |
542 | QList<QByteArray> list; | - |
543 | return list; executed: return list; Execution Count:146 | 146 |
544 | } | - |
545 | | - |
546 | QUtf32Codec::~QUtf32Codec() | - |
547 | { | - |
548 | } | - |
549 | | - |
550 | QByteArray QUtf32Codec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const | - |
551 | { | - |
552 | return QUtf32::convertFromUnicode(uc, len, state, e); executed: return QUtf32::convertFromUnicode(uc, len, state, e); Execution Count:85728 | 85728 |
553 | } | - |
554 | | - |
555 | QString QUtf32Codec::convertToUnicode(const char *chars, int len, ConverterState *state) const | - |
556 | { | - |
557 | return QUtf32::convertToUnicode(chars, len, state, e); executed: return QUtf32::convertToUnicode(chars, len, state, e); Execution Count:1094 | 1094 |
558 | } | - |
559 | | - |
560 | int QUtf32Codec::mibEnum() const | - |
561 | { | - |
562 | return 1017; executed: return 1017; Execution Count:28 | 28 |
563 | } | - |
564 | | - |
565 | QByteArray QUtf32Codec::name() const | - |
566 | { | - |
567 | return "UTF-32"; executed: return "UTF-32"; Execution Count:137 | 137 |
568 | } | - |
569 | | - |
570 | QList<QByteArray> QUtf32Codec::aliases() const | - |
571 | { | - |
572 | QList<QByteArray> list; | - |
573 | return list; executed: return list; Execution Count:125 | 125 |
574 | } | - |
575 | | - |
576 | int QUtf32BECodec::mibEnum() const | - |
577 | { | - |
578 | return 1018; executed: return 1018; Execution Count:21 | 21 |
579 | } | - |
580 | | - |
581 | QByteArray QUtf32BECodec::name() const | - |
582 | { | - |
583 | return "UTF-32BE"; executed: return "UTF-32BE"; Execution Count:128 | 128 |
584 | } | - |
585 | | - |
586 | QList<QByteArray> QUtf32BECodec::aliases() const | - |
587 | { | - |
588 | QList<QByteArray> list; | - |
589 | return list; executed: return list; Execution Count:127 | 127 |
590 | } | - |
591 | | - |
592 | int QUtf32LECodec::mibEnum() const | - |
593 | { | - |
594 | return 1019; executed: return 1019; Execution Count:23 | 23 |
595 | } | - |
596 | | - |
597 | QByteArray QUtf32LECodec::name() const | - |
598 | { | - |
599 | return "UTF-32LE"; executed: return "UTF-32LE"; Execution Count:127 | 127 |
600 | } | - |
601 | | - |
602 | QList<QByteArray> QUtf32LECodec::aliases() const | - |
603 | { | - |
604 | QList<QByteArray> list; | - |
605 | return list; executed: return list; Execution Count:126 | 126 |
606 | } | - |
607 | | - |
608 | | - |
609 | | - |
610 | | - |
611 | | - |
| | |