42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
size_t length, bool lossy)
{
size_t i;
for (i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY ((c >= 0x80 && c <= 0x9F) || c > 0xFFFF) {
if (lossy)
output[i] = '?';
else
return false;
}
if OF_UNLIKELY (c > 0xFF) {
switch ((of_char16_t)c) {
case 0x20AC:
output[i] = 0x80;
break;
case 0x201A:
output[i] = 0x82;
break;
|
|
>
|
|
>
|
|
|
<
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
size_t length, bool lossy)
{
size_t i;
for (i = 0; i < length; i++) {
of_unichar_t c = input[i];
if OF_UNLIKELY (c > 0xFF) {
if OF_UNLIKELY (c > 0xFFFF) {
if (lossy) {
output[i] = '?';
continue;
} else
return false;
}
switch ((of_char16_t)c) {
case 0x20AC:
output[i] = 0x80;
break;
case 0x201A:
output[i] = 0x82;
break;
|
140
141
142
143
144
145
146
147
148
149
150
151
152
|
if (lossy)
output[i] = '?';
else
return false;
break;
}
} else
output[i] = (uint8_t)c;
}
return true;
}
|
>
>
>
>
>
>
|
|
>
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
if (lossy)
output[i] = '?';
else
return false;
break;
}
} else {
if OF_UNLIKELY (c >= 0x80 && c <= 0x9F) {
if (lossy)
output[i] = '?';
else
return false;
} else
output[i] = (uint8_t)c;
}
}
return true;
}
|