codecs/qlatincodec.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6QLatin1Codec::~QLatin1Codec() -
7{ -
8} -
9 -
10QString QLatin1Codec::convertToUnicode(const char *chars, int len, ConverterState *) const -
11{ -
12 if (chars == 0)
partially evaluated: chars == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:107
0-107
13 return QString();
never executed: return QString();
0
14 -
15 return QString::fromLatin1(chars, len);
executed: return QString::fromLatin1(chars, len);
Execution Count:107
107
16} -
17 -
18 -
19QByteArray QLatin1Codec::convertFromUnicode(const QChar *ch, int len, ConverterState *state) const -
20{ -
21 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
22 QByteArray r(len, Qt::Uninitialized); -
23 char *d = r.data(); -
24 int invalid = 0; -
25 for (int i = 0; i < len; ++i) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:10439
yes
Evaluation Count:77
77-10439
26 if (ch[i] > 0xff) {
partially evaluated: ch[i] > 0xff
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10439
0-10439
27 d[i] = replacement; -
28 ++invalid; -
29 } else {
never executed: }
0
30 d[i] = (char)ch[i].cell(); -
31 }
executed: }
Execution Count:10439
10439
32 } -
33 if (state) {
evaluated: state
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:40
37-40
34 state->invalidChars += invalid; -
35 }
executed: }
Execution Count:37
37
36 return r;
executed: return r;
Execution Count:77
77
37} -
38 -
39QByteArray QLatin1Codec::name() const -
40{ -
41 return "ISO-8859-1";
executed: return "ISO-8859-1";
Execution Count:133
133
42} -
43 -
44QList<QByteArray> QLatin1Codec::aliases() const -
45{ -
46 QList<QByteArray> list; -
47 list << "latin1" -
48 << "CP819" -
49 << "IBM819" -
50 << "iso-ir-100" -
51 << "csISOLatin1"; -
52 return list;
executed: return list;
Execution Count:128
128
53} -
54 -
55 -
56int QLatin1Codec::mibEnum() const -
57{ -
58 return 4;
executed: return 4;
Execution Count:29
29
59} -
60 -
61 -
62QLatin15Codec::~QLatin15Codec() -
63{ -
64} -
65 -
66QString QLatin15Codec::convertToUnicode(const char* chars, int len, ConverterState *) const -
67{ -
68 if (chars == 0)
never evaluated: chars == 0
0
69 return QString();
never executed: return QString();
0
70 -
71 QString str = QString::fromLatin1(chars, len); -
72 QChar *uc = str.data(); -
73 while(len--) {
never evaluated: len--
0
74 switch(uc->unicode()) { -
75 case 0xa4: -
76 *uc = 0x20ac; -
77 break;
never executed: break;
0
78 case 0xa6: -
79 *uc = 0x0160; -
80 break;
never executed: break;
0
81 case 0xa8: -
82 *uc = 0x0161; -
83 break;
never executed: break;
0
84 case 0xb4: -
85 *uc = 0x017d; -
86 break;
never executed: break;
0
87 case 0xb8: -
88 *uc = 0x017e; -
89 break;
never executed: break;
0
90 case 0xbc: -
91 *uc = 0x0152; -
92 break;
never executed: break;
0
93 case 0xbd: -
94 *uc = 0x0153; -
95 break;
never executed: break;
0
96 case 0xbe: -
97 *uc = 0x0178; -
98 break;
never executed: break;
0
99 default: -
100 break;
never executed: break;
0
101 } -
102 uc++; -
103 }
never executed: }
0
104 return str;
never executed: return str;
0
105} -
106 -
107QByteArray QLatin15Codec::convertFromUnicode(const QChar *in, int length, ConverterState *state) const -
108{ -
109 const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?';
never evaluated: state
never evaluated: state->flags & ConvertInvalidToNull
0
110 QByteArray r(length, Qt::Uninitialized); -
111 char *d = r.data(); -
112 int invalid = 0; -
113 for (int i = 0; i < length; ++i) {
never evaluated: i < length
0
114 uchar c; -
115 ushort uc = in[i].unicode(); -
116 if (uc < 0x0100) {
never evaluated: uc < 0x0100
0
117 if (uc > 0xa3) {
never evaluated: uc > 0xa3
0
118 switch(uc) { -
119 case 0xa4: -
120 case 0xa6: -
121 case 0xa8: -
122 case 0xb4: -
123 case 0xb8: -
124 case 0xbc: -
125 case 0xbd: -
126 case 0xbe: -
127 c = replacement; -
128 ++invalid; -
129 break;
never executed: break;
0
130 default: -
131 c = (unsigned char) uc; -
132 break;
never executed: break;
0
133 } -
134 } else {
never executed: }
0
135 c = (unsigned char) uc; -
136 }
never executed: }
0
137 } else { -
138 if (uc == 0x20ac)
never evaluated: uc == 0x20ac
0
139 c = 0xa4;
never executed: c = 0xa4;
0
140 else if ((uc & 0xff00) == 0x0100) {
never evaluated: (uc & 0xff00) == 0x0100
0
141 switch(uc) { -
142 case 0x0160: -
143 c = 0xa6; -
144 break;
never executed: break;
0
145 case 0x0161: -
146 c = 0xa8; -
147 break;
never executed: break;
0
148 case 0x017d: -
149 c = 0xb4; -
150 break;
never executed: break;
0
151 case 0x017e: -
152 c = 0xb8; -
153 break;
never executed: break;
0
154 case 0x0152: -
155 c = 0xbc; -
156 break;
never executed: break;
0
157 case 0x0153: -
158 c = 0xbd; -
159 break;
never executed: break;
0
160 case 0x0178: -
161 c = 0xbe; -
162 break;
never executed: break;
0
163 default: -
164 c = replacement; -
165 ++invalid; -
166 }
never executed: }
0
167 } else {
never executed: }
0
168 c = replacement; -
169 ++invalid; -
170 }
never executed: }
0
171 } -
172 d[i] = (char)c; -
173 }
never executed: }
0
174 if (state) {
never evaluated: state
0
175 state->remainingChars = 0; -
176 state->invalidChars += invalid; -
177 }
never executed: }
0
178 return r;
never executed: return r;
0
179} -
180 -
181 -
182QByteArray QLatin15Codec::name() const -
183{ -
184 return "ISO-8859-15";
never executed: return "ISO-8859-15";
0
185} -
186 -
187QList<QByteArray> QLatin15Codec::aliases() const -
188{ -
189 QList<QByteArray> list; -
190 list << "latin9"; -
191 return list;
never executed: return list;
0
192} -
193 -
194int QLatin15Codec::mibEnum() const -
195{ -
196 return 111;
never executed: return 111;
0
197} -
198 -
199 -
200 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial