1 | /* $Id: fsw_strfunc.h 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * fsw_strfunc.h
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | /* fsw_strfunc.h generated by mk_fsw_strfunc.py */
|
---|
28 |
|
---|
29 | static int fsw_streq_ISO88591_UTF8(void *s1data, void *s2data, int len)
|
---|
30 | {
|
---|
31 | int i;
|
---|
32 | fsw_u8 *p1 = (fsw_u8 *)s1data;
|
---|
33 | fsw_u8 *p2 = (fsw_u8 *)s2data;
|
---|
34 | fsw_u32 c1, c2;
|
---|
35 |
|
---|
36 | for (i = 0; i < len; i++) {
|
---|
37 | c1 = *p1++;
|
---|
38 | c2 = *p2++;
|
---|
39 | if ((c2 & 0xe0) == 0xc0) {
|
---|
40 | c2 = ((c2 & 0x1f) << 6) | (*p2++ & 0x3f);
|
---|
41 | } else if ((c2 & 0xf0) == 0xe0) {
|
---|
42 | c2 = ((c2 & 0x0f) << 12) | ((*p2++ & 0x3f) << 6);
|
---|
43 | c2 |= (*p2++ & 0x3f);
|
---|
44 | } else if ((c2 & 0xf8) == 0xf0) {
|
---|
45 | c2 = ((c2 & 0x07) << 18) | ((*p2++ & 0x3f) << 12);
|
---|
46 | c2 |= ((*p2++ & 0x3f) << 6);
|
---|
47 | c2 |= (*p2++ & 0x3f);
|
---|
48 | }
|
---|
49 | if (c1 != c2)
|
---|
50 | return 0;
|
---|
51 | }
|
---|
52 | return 1;
|
---|
53 | }
|
---|
54 |
|
---|
55 | #ifndef HOST_EFI
|
---|
56 | static int fsw_streq_ISO88591_UTF16(void *s1data, void *s2data, int len)
|
---|
57 | {
|
---|
58 | int i;
|
---|
59 | fsw_u8 *p1 = (fsw_u8 *)s1data;
|
---|
60 | fsw_u16 *p2 = (fsw_u16 *)s2data;
|
---|
61 | fsw_u32 c1, c2;
|
---|
62 |
|
---|
63 | for (i = 0; i < len; i++) {
|
---|
64 | c1 = *p1++;
|
---|
65 | c2 = *p2++;
|
---|
66 | if (c1 != c2)
|
---|
67 | return 0;
|
---|
68 | }
|
---|
69 | return 1;
|
---|
70 | }
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | static int fsw_streq_ISO88591_UTF16_SWAPPED(void *s1data, void *s2data, int len)
|
---|
74 | {
|
---|
75 | int i;
|
---|
76 | fsw_u8 *p1 = (fsw_u8 *)s1data;
|
---|
77 | fsw_u16 *p2 = (fsw_u16 *)s2data;
|
---|
78 | fsw_u32 c1, c2;
|
---|
79 |
|
---|
80 | for (i = 0; i < len; i++) {
|
---|
81 | c1 = *p1++;
|
---|
82 | c2 = *p2++; c2 = FSW_SWAPVALUE_U16(c2);
|
---|
83 | if (c1 != c2)
|
---|
84 | return 0;
|
---|
85 | }
|
---|
86 | return 1;
|
---|
87 | }
|
---|
88 |
|
---|
89 | static int fsw_streq_UTF8_UTF16(void *s1data, void *s2data, int len)
|
---|
90 | {
|
---|
91 | int i;
|
---|
92 | fsw_u8 *p1 = (fsw_u8 *)s1data;
|
---|
93 | fsw_u16 *p2 = (fsw_u16 *)s2data;
|
---|
94 | fsw_u32 c1, c2;
|
---|
95 |
|
---|
96 | for (i = 0; i < len; i++) {
|
---|
97 | c1 = *p1++;
|
---|
98 | if ((c1 & 0xe0) == 0xc0) {
|
---|
99 | c1 = ((c1 & 0x1f) << 6) | (*p1++ & 0x3f);
|
---|
100 | } else if ((c1 & 0xf0) == 0xe0) {
|
---|
101 | c1 = ((c1 & 0x0f) << 12) | ((*p1++ & 0x3f) << 6);
|
---|
102 | c1 |= (*p1++ & 0x3f);
|
---|
103 | } else if ((c1 & 0xf8) == 0xf0) {
|
---|
104 | c1 = ((c1 & 0x07) << 18) | ((*p1++ & 0x3f) << 12);
|
---|
105 | c1 |= ((*p1++ & 0x3f) << 6);
|
---|
106 | c1 |= (*p1++ & 0x3f);
|
---|
107 | }
|
---|
108 | c2 = *p2++;
|
---|
109 | if (c1 != c2)
|
---|
110 | return 0;
|
---|
111 | }
|
---|
112 | return 1;
|
---|
113 | }
|
---|
114 |
|
---|
115 | static int fsw_streq_UTF8_UTF16_SWAPPED(void *s1data, void *s2data, int len)
|
---|
116 | {
|
---|
117 | int i;
|
---|
118 | fsw_u8 *p1 = (fsw_u8 *)s1data;
|
---|
119 | fsw_u16 *p2 = (fsw_u16 *)s2data;
|
---|
120 | fsw_u32 c1, c2;
|
---|
121 |
|
---|
122 | for (i = 0; i < len; i++) {
|
---|
123 | c1 = *p1++;
|
---|
124 | if ((c1 & 0xe0) == 0xc0) {
|
---|
125 | c1 = ((c1 & 0x1f) << 6) | (*p1++ & 0x3f);
|
---|
126 | } else if ((c1 & 0xf0) == 0xe0) {
|
---|
127 | c1 = ((c1 & 0x0f) << 12) | ((*p1++ & 0x3f) << 6);
|
---|
128 | c1 |= (*p1++ & 0x3f);
|
---|
129 | } else if ((c1 & 0xf8) == 0xf0) {
|
---|
130 | c1 = ((c1 & 0x07) << 18) | ((*p1++ & 0x3f) << 12);
|
---|
131 | c1 |= ((*p1++ & 0x3f) << 6);
|
---|
132 | c1 |= (*p1++ & 0x3f);
|
---|
133 | }
|
---|
134 | c2 = *p2++; c2 = FSW_SWAPVALUE_U16(c2);
|
---|
135 | if (c1 != c2)
|
---|
136 | return 0;
|
---|
137 | }
|
---|
138 | return 1;
|
---|
139 | }
|
---|
140 |
|
---|
141 | static int fsw_streq_UTF16_UTF16_SWAPPED(void *s1data, void *s2data, int len)
|
---|
142 | {
|
---|
143 | int i;
|
---|
144 | fsw_u16 *p1 = (fsw_u16 *)s1data;
|
---|
145 | fsw_u16 *p2 = (fsw_u16 *)s2data;
|
---|
146 | fsw_u32 c1, c2;
|
---|
147 |
|
---|
148 | for (i = 0; i < len; i++) {
|
---|
149 | c1 = *p1++;
|
---|
150 | c2 = *p2++; c2 = FSW_SWAPVALUE_U16(c2);
|
---|
151 | if (c1 != c2)
|
---|
152 | return 0;
|
---|
153 | }
|
---|
154 | return 1;
|
---|
155 | }
|
---|
156 |
|
---|
157 | static fsw_status_t fsw_strcoerce_UTF8_ISO88591(void *srcdata, int srclen, struct fsw_string *dest)
|
---|
158 | {
|
---|
159 | fsw_status_t status;
|
---|
160 | int i;
|
---|
161 | fsw_u8 *sp;
|
---|
162 | fsw_u8 *dp;
|
---|
163 | fsw_u32 c;
|
---|
164 |
|
---|
165 | dest->type = FSW_STRING_TYPE_ISO88591;
|
---|
166 | dest->len = srclen;
|
---|
167 | dest->size = srclen * sizeof(fsw_u8);
|
---|
168 | status = fsw_alloc(dest->size, &dest->data);
|
---|
169 | if (status)
|
---|
170 | return status;
|
---|
171 |
|
---|
172 | sp = (fsw_u8 *)srcdata;
|
---|
173 | dp = (fsw_u8 *)dest->data;
|
---|
174 | for (i = 0; i < srclen; i++) {
|
---|
175 | c = *sp++;
|
---|
176 | if ((c & 0xe0) == 0xc0) {
|
---|
177 | c = ((c & 0x1f) << 6) | (*sp++ & 0x3f);
|
---|
178 | } else if ((c & 0xf0) == 0xe0) {
|
---|
179 | c = ((c & 0x0f) << 12) | ((*sp++ & 0x3f) << 6);
|
---|
180 | c |= (*sp++ & 0x3f);
|
---|
181 | } else if ((c & 0xf8) == 0xf0) {
|
---|
182 | c = ((c & 0x07) << 18) | ((*sp++ & 0x3f) << 12);
|
---|
183 | c |= ((*sp++ & 0x3f) << 6);
|
---|
184 | c |= (*sp++ & 0x3f);
|
---|
185 | }
|
---|
186 | *dp++ = (fsw_u8)c;
|
---|
187 | }
|
---|
188 | return FSW_SUCCESS;
|
---|
189 | }
|
---|
190 |
|
---|
191 | static fsw_status_t fsw_strcoerce_UTF16_ISO88591(void *srcdata, int srclen, struct fsw_string *dest)
|
---|
192 | {
|
---|
193 | fsw_status_t status;
|
---|
194 | int i;
|
---|
195 | fsw_u16 *sp;
|
---|
196 | fsw_u8 *dp;
|
---|
197 | fsw_u32 c;
|
---|
198 |
|
---|
199 | dest->type = FSW_STRING_TYPE_ISO88591;
|
---|
200 | dest->len = srclen;
|
---|
201 | dest->size = srclen * sizeof(fsw_u8);
|
---|
202 | status = fsw_alloc(dest->size, &dest->data);
|
---|
203 | if (status)
|
---|
204 | return status;
|
---|
205 |
|
---|
206 | sp = (fsw_u16 *)srcdata;
|
---|
207 | dp = (fsw_u8 *)dest->data;
|
---|
208 | for (i = 0; i < srclen; i++) {
|
---|
209 | c = *sp++;
|
---|
210 | *dp++ = (fsw_u8)c;
|
---|
211 | }
|
---|
212 | return FSW_SUCCESS;
|
---|
213 | }
|
---|
214 |
|
---|
215 | static fsw_status_t fsw_strcoerce_UTF16_SWAPPED_ISO88591(void *srcdata, int srclen, struct fsw_string *dest)
|
---|
216 | {
|
---|
217 | fsw_status_t status;
|
---|
218 | int i;
|
---|
219 | fsw_u16 *sp;
|
---|
220 | fsw_u8 *dp;
|
---|
221 | fsw_u32 c;
|
---|
222 |
|
---|
223 | dest->type = FSW_STRING_TYPE_ISO88591;
|
---|
224 | dest->len = srclen;
|
---|
225 | dest->size = srclen * sizeof(fsw_u8);
|
---|
226 | status = fsw_alloc(dest->size, &dest->data);
|
---|
227 | if (status)
|
---|
228 | return status;
|
---|
229 |
|
---|
230 | sp = (fsw_u16 *)srcdata;
|
---|
231 | dp = (fsw_u8 *)dest->data;
|
---|
232 | for (i = 0; i < srclen; i++) {
|
---|
233 | c = *sp++; c = FSW_SWAPVALUE_U16(c);
|
---|
234 | *dp++ = (fsw_u8)c;
|
---|
235 | }
|
---|
236 | return FSW_SUCCESS;
|
---|
237 | }
|
---|
238 |
|
---|
239 | static fsw_status_t fsw_strcoerce_ISO88591_UTF16(void *srcdata, int srclen, struct fsw_string *dest)
|
---|
240 | {
|
---|
241 | fsw_status_t status;
|
---|
242 | int i;
|
---|
243 | fsw_u8 *sp;
|
---|
244 | fsw_u16 *dp;
|
---|
245 | fsw_u32 c;
|
---|
246 |
|
---|
247 | dest->type = FSW_STRING_TYPE_UTF16;
|
---|
248 | dest->len = srclen;
|
---|
249 | dest->size = srclen * sizeof(fsw_u16);
|
---|
250 | status = fsw_alloc(dest->size, &dest->data);
|
---|
251 | if (status)
|
---|
252 | return status;
|
---|
253 |
|
---|
254 | sp = (fsw_u8 *)srcdata;
|
---|
255 | dp = (fsw_u16 *)dest->data;
|
---|
256 | for (i = 0; i < srclen; i++) {
|
---|
257 | c = *sp++;
|
---|
258 | *dp++ = (fsw_u16)c;
|
---|
259 | }
|
---|
260 | return FSW_SUCCESS;
|
---|
261 | }
|
---|
262 |
|
---|
263 | static fsw_status_t fsw_strcoerce_UTF8_UTF16(void *srcdata, int srclen, struct fsw_string *dest)
|
---|
264 | {
|
---|
265 | fsw_status_t status;
|
---|
266 | int i;
|
---|
267 | fsw_u8 *sp;
|
---|
268 | fsw_u16 *dp;
|
---|
269 | fsw_u32 c;
|
---|
270 |
|
---|
271 | dest->type = FSW_STRING_TYPE_UTF16;
|
---|
272 | dest->len = srclen;
|
---|
273 | dest->size = srclen * sizeof(fsw_u16);
|
---|
274 | status = fsw_alloc(dest->size, &dest->data);
|
---|
275 | if (status)
|
---|
276 | return status;
|
---|
277 |
|
---|
278 | sp = (fsw_u8 *)srcdata;
|
---|
279 | dp = (fsw_u16 *)dest->data;
|
---|
280 | for (i = 0; i < srclen; i++) {
|
---|
281 | c = *sp++;
|
---|
282 | if ((c & 0xe0) == 0xc0) {
|
---|
283 | c = ((c & 0x1f) << 6) | (*sp++ & 0x3f);
|
---|
284 | } else if ((c & 0xf0) == 0xe0) {
|
---|
285 | c = ((c & 0x0f) << 12) | ((*sp++ & 0x3f) << 6);
|
---|
286 | c |= (*sp++ & 0x3f);
|
---|
287 | } else if ((c & 0xf8) == 0xf0) {
|
---|
288 | c = ((c & 0x07) << 18) | ((*sp++ & 0x3f) << 12);
|
---|
289 | c |= ((*sp++ & 0x3f) << 6);
|
---|
290 | c |= (*sp++ & 0x3f);
|
---|
291 | }
|
---|
292 | *dp++ = (fsw_u16)c;
|
---|
293 | }
|
---|
294 | return FSW_SUCCESS;
|
---|
295 | }
|
---|
296 |
|
---|
297 | static fsw_status_t fsw_strcoerce_UTF16_SWAPPED_UTF16(void *srcdata, int srclen, struct fsw_string *dest)
|
---|
298 | {
|
---|
299 | fsw_status_t status;
|
---|
300 | int i;
|
---|
301 | fsw_u16 *sp;
|
---|
302 | fsw_u16 *dp;
|
---|
303 | fsw_u32 c;
|
---|
304 |
|
---|
305 | dest->type = FSW_STRING_TYPE_UTF16;
|
---|
306 | dest->len = srclen;
|
---|
307 | dest->size = srclen * sizeof(fsw_u16);
|
---|
308 | status = fsw_alloc(dest->size, &dest->data);
|
---|
309 | if (status)
|
---|
310 | return status;
|
---|
311 |
|
---|
312 | sp = (fsw_u16 *)srcdata;
|
---|
313 | dp = (fsw_u16 *)dest->data;
|
---|
314 | for (i = 0; i < srclen; i++) {
|
---|
315 | c = *sp++; c = FSW_SWAPVALUE_U16(c);
|
---|
316 | *dp++ = (fsw_u16)c;
|
---|
317 | }
|
---|
318 | return FSW_SUCCESS;
|
---|
319 | }
|
---|
320 |
|
---|
321 | static fsw_status_t fsw_strcoerce_ISO88591_UTF8(void *srcdata, int srclen, struct fsw_string *dest)
|
---|
322 | {
|
---|
323 | fsw_status_t status;
|
---|
324 | int i, destsize;
|
---|
325 | fsw_u8 *sp;
|
---|
326 | fsw_u8 *dp;
|
---|
327 | fsw_u32 c;
|
---|
328 |
|
---|
329 | sp = (fsw_u8 *)srcdata;
|
---|
330 | destsize = 0;
|
---|
331 | for (i = 0; i < srclen; i++) {
|
---|
332 | c = *sp++;
|
---|
333 |
|
---|
334 | if (c < 0x000080)
|
---|
335 | destsize++;
|
---|
336 | else if (c < 0x000800)
|
---|
337 | destsize += 2;
|
---|
338 | else if (c < 0x010000)
|
---|
339 | destsize += 3;
|
---|
340 | else
|
---|
341 | destsize += 4;
|
---|
342 | }
|
---|
343 |
|
---|
344 | dest->type = FSW_STRING_TYPE_UTF8;
|
---|
345 | dest->len = srclen;
|
---|
346 | dest->size = destsize;
|
---|
347 | status = fsw_alloc(dest->size, &dest->data);
|
---|
348 | if (status)
|
---|
349 | return status;
|
---|
350 |
|
---|
351 | sp = (fsw_u8 *)srcdata;
|
---|
352 | dp = (fsw_u8 *)dest->data;
|
---|
353 | for (i = 0; i < srclen; i++) {
|
---|
354 | c = *sp++;
|
---|
355 |
|
---|
356 | if (c < 0x000080) {
|
---|
357 | *dp++ = (fsw_u8)c;
|
---|
358 | } else if (c < 0x000800) {
|
---|
359 | *dp++ = (fsw_u8)(0xc0 | ((c >> 6) & 0x1f));
|
---|
360 | *dp++ = (fsw_u8)(0x80 | (c & 0x3f));
|
---|
361 | } else if (c < 0x010000) {
|
---|
362 | *dp++ = (fsw_u8)(0xe0 | ((c >> 12) & 0x0f));
|
---|
363 | *dp++ = (fsw_u8)(0x80 | ((c >> 6) & 0x3f));
|
---|
364 | *dp++ = (fsw_u8)(0x80 | (c & 0x3f));
|
---|
365 | } else {
|
---|
366 | *dp++ = (fsw_u8)(0xf0 | ((c >> 18) & 0x07));
|
---|
367 | *dp++ = (fsw_u8)(0x80 | ((c >> 12) & 0x3f));
|
---|
368 | *dp++ = (fsw_u8)(0x80 | ((c >> 6) & 0x3f));
|
---|
369 | *dp++ = (fsw_u8)(0x80 | (c & 0x3f));
|
---|
370 | }
|
---|
371 | }
|
---|
372 | return FSW_SUCCESS;
|
---|
373 | }
|
---|
374 |
|
---|
375 | static fsw_status_t fsw_strcoerce_UTF16_UTF8(void *srcdata, int srclen, struct fsw_string *dest)
|
---|
376 | {
|
---|
377 | fsw_status_t status;
|
---|
378 | int i, destsize;
|
---|
379 | fsw_u16 *sp;
|
---|
380 | fsw_u8 *dp;
|
---|
381 | fsw_u32 c;
|
---|
382 |
|
---|
383 | sp = (fsw_u16 *)srcdata;
|
---|
384 | destsize = 0;
|
---|
385 | for (i = 0; i < srclen; i++) {
|
---|
386 | c = *sp++;
|
---|
387 |
|
---|
388 | if (c < 0x000080)
|
---|
389 | destsize++;
|
---|
390 | else if (c < 0x000800)
|
---|
391 | destsize += 2;
|
---|
392 | else if (c < 0x010000)
|
---|
393 | destsize += 3;
|
---|
394 | else
|
---|
395 | destsize += 4;
|
---|
396 | }
|
---|
397 |
|
---|
398 | dest->type = FSW_STRING_TYPE_UTF8;
|
---|
399 | dest->len = srclen;
|
---|
400 | dest->size = destsize;
|
---|
401 | status = fsw_alloc(dest->size, &dest->data);
|
---|
402 | if (status)
|
---|
403 | return status;
|
---|
404 |
|
---|
405 | sp = (fsw_u16 *)srcdata;
|
---|
406 | dp = (fsw_u8 *)dest->data;
|
---|
407 | for (i = 0; i < srclen; i++) {
|
---|
408 | c = *sp++;
|
---|
409 |
|
---|
410 | if (c < 0x000080) {
|
---|
411 | *dp++ = (fsw_u8)c;
|
---|
412 | } else if (c < 0x000800) {
|
---|
413 | *dp++ = (fsw_u8)(0xc0 | ((c >> 6) & 0x1f));
|
---|
414 | *dp++ = (fsw_u8)(0x80 | (c & 0x3f));
|
---|
415 | } else if (c < 0x010000) {
|
---|
416 | *dp++ = (fsw_u8)(0xe0 | ((c >> 12) & 0x0f));
|
---|
417 | *dp++ = (fsw_u8)(0x80 | ((c >> 6) & 0x3f));
|
---|
418 | *dp++ = (fsw_u8)(0x80 | (c & 0x3f));
|
---|
419 | } else {
|
---|
420 | *dp++ = (fsw_u8)(0xf0 | ((c >> 18) & 0x07));
|
---|
421 | *dp++ = (fsw_u8)(0x80 | ((c >> 12) & 0x3f));
|
---|
422 | *dp++ = (fsw_u8)(0x80 | ((c >> 6) & 0x3f));
|
---|
423 | *dp++ = (fsw_u8)(0x80 | (c & 0x3f));
|
---|
424 | }
|
---|
425 | }
|
---|
426 | return FSW_SUCCESS;
|
---|
427 | }
|
---|
428 |
|
---|
429 | static fsw_status_t fsw_strcoerce_UTF16_SWAPPED_UTF8(void *srcdata, int srclen, struct fsw_string *dest)
|
---|
430 | {
|
---|
431 | fsw_status_t status;
|
---|
432 | int i, destsize;
|
---|
433 | fsw_u16 *sp;
|
---|
434 | fsw_u8 *dp;
|
---|
435 | fsw_u32 c;
|
---|
436 |
|
---|
437 | sp = (fsw_u16 *)srcdata;
|
---|
438 | destsize = 0;
|
---|
439 | for (i = 0; i < srclen; i++) {
|
---|
440 | c = *sp++; c = FSW_SWAPVALUE_U16(c);
|
---|
441 |
|
---|
442 | if (c < 0x000080)
|
---|
443 | destsize++;
|
---|
444 | else if (c < 0x000800)
|
---|
445 | destsize += 2;
|
---|
446 | else if (c < 0x010000)
|
---|
447 | destsize += 3;
|
---|
448 | else
|
---|
449 | destsize += 4;
|
---|
450 | }
|
---|
451 |
|
---|
452 | dest->type = FSW_STRING_TYPE_UTF8;
|
---|
453 | dest->len = srclen;
|
---|
454 | dest->size = destsize;
|
---|
455 | status = fsw_alloc(dest->size, &dest->data);
|
---|
456 | if (status)
|
---|
457 | return status;
|
---|
458 |
|
---|
459 | sp = (fsw_u16 *)srcdata;
|
---|
460 | dp = (fsw_u8 *)dest->data;
|
---|
461 | for (i = 0; i < srclen; i++) {
|
---|
462 | c = *sp++; c = FSW_SWAPVALUE_U16(c);
|
---|
463 |
|
---|
464 | if (c < 0x000080) {
|
---|
465 | *dp++ = (fsw_u8)c;
|
---|
466 | } else if (c < 0x000800) {
|
---|
467 | *dp++ = (fsw_u8)(0xc0 | ((c >> 6) & 0x1f));
|
---|
468 | *dp++ = (fsw_u8)(0x80 | (c & 0x3f));
|
---|
469 | } else if (c < 0x010000) {
|
---|
470 | *dp++ = (fsw_u8)(0xe0 | ((c >> 12) & 0x0f));
|
---|
471 | *dp++ = (fsw_u8)(0x80 | ((c >> 6) & 0x3f));
|
---|
472 | *dp++ = (fsw_u8)(0x80 | (c & 0x3f));
|
---|
473 | } else {
|
---|
474 | *dp++ = (fsw_u8)(0xf0 | ((c >> 18) & 0x07));
|
---|
475 | *dp++ = (fsw_u8)(0x80 | ((c >> 12) & 0x3f));
|
---|
476 | *dp++ = (fsw_u8)(0x80 | ((c >> 6) & 0x3f));
|
---|
477 | *dp++ = (fsw_u8)(0x80 | (c & 0x3f));
|
---|
478 | }
|
---|
479 | }
|
---|
480 | return FSW_SUCCESS;
|
---|
481 | }
|
---|