1 /*
2 Copyright (c) 1990 Regents of the University of California.
3 All rights reserved.
4 */
5 #include <errno.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <wchar.h>
9 #include <locale.h>
10 #include <stdint.h>
11 #include "mbctype.h"
12 #include "local.h"
13
14 int
__ascii_wctomb(char * s,wchar_t _wchar,mbstate_t * state)15 __ascii_wctomb (
16 char *s,
17 wchar_t _wchar,
18 mbstate_t *state)
19 {
20 /* Avoids compiler warnings about comparisons that are always false
21 due to limited range when sizeof(wchar_t) is 2 but sizeof(wint_t)
22 is 4, as is the case on cygwin. */
23 wint_t wchar = _wchar;
24
25 (void) state;
26 if (s == NULL)
27 return 0;
28
29 if ((size_t)wchar >= 0x100)
30 {
31 _REENT_ERRNO(r) = EILSEQ;
32 return -1;
33 }
34
35 *s = (char) wchar;
36 return 1;
37 }
38
39 #ifdef _MB_CAPABLE
40 /* for some conversions, we use the __count field as a place to store a state value */
41 #define __state __count
42
43 int
__utf8_wctomb(char * s,wchar_t _wchar,mbstate_t * state)44 __utf8_wctomb (
45 char *s,
46 wchar_t _wchar,
47 mbstate_t *state)
48 {
49 uint32_t wchar = _wchar;
50 int ret = 0;
51
52 if (s == NULL)
53 return 0; /* UTF-8 encoding is not state-dependent */
54
55 if (sizeof (wchar_t) == 2 && state->__count == -4
56 && (wchar < 0xdc00 || wchar > 0xdfff))
57 {
58 /* There's a leftover lone high surrogate. Write out the CESU-8 value
59 of the surrogate and proceed to convert the given character. Note
60 to return extra 3 bytes. */
61 wchar_t tmp;
62 tmp = ((uint32_t) state->__value.__wchb[0] << 16 | (uint32_t) state->__value.__wchb[1] << 8)
63 - ((uint32_t) 0x10000 >> 10 | (uint32_t) 0xd80d);
64 *s++ = 0xe0 | ((tmp & 0xf000) >> 12);
65 *s++ = 0x80 | ((tmp & 0xfc0) >> 6);
66 *s++ = 0x80 | (tmp & 0x3f);
67 state->__count = 0;
68 ret = 3;
69 }
70 if (wchar <= 0x7f)
71 {
72 *s = wchar;
73 return ret + 1;
74 }
75 if (wchar >= 0x80 && wchar <= 0x7ff)
76 {
77 *s++ = 0xc0 | ((wchar & 0x7c0) >> 6);
78 *s = 0x80 | (wchar & 0x3f);
79 return ret + 2;
80 }
81 if (wchar >= 0x800 && wchar <= 0xffff)
82 {
83 /* No UTF-16 surrogate handling in UCS-4 */
84 if (sizeof (wchar_t) == 2 && wchar >= 0xd800 && wchar <= 0xdfff)
85 {
86 uint32_t tmp;
87 if (wchar <= 0xdbff)
88 {
89 /* First half of a surrogate pair. Store the state and
90 return ret + 0. */
91 tmp = ((wchar & 0x3ff) << 10) + 0x10000;
92 state->__value.__wchb[0] = (tmp >> 16) & 0xff;
93 state->__value.__wchb[1] = (tmp >> 8) & 0xff;
94 state->__count = -4;
95 *s = (0xf0 | ((tmp & 0x1c0000) >> 18));
96 return ret;
97 }
98 if (state->__count == -4)
99 {
100 /* Second half of a surrogate pair. Reconstruct the full
101 Unicode value and return the trailing three bytes of the
102 UTF-8 character. */
103 tmp = ((uint32_t) state->__value.__wchb[0] << 16)
104 | (state->__value.__wchb[1] << 8)
105 | (wchar & 0x3ff);
106 state->__count = 0;
107 *s++ = 0xf0 | ((tmp & 0x1c0000) >> 18);
108 *s++ = 0x80 | ((tmp & 0x3f000) >> 12);
109 *s++ = 0x80 | ((tmp & 0xfc0) >> 6);
110 *s = 0x80 | (tmp & 0x3f);
111 return 4;
112 }
113 /* Otherwise translate into CESU-8 value. */
114 }
115 *s++ = 0xe0 | ((wchar & 0xf000) >> 12);
116 *s++ = 0x80 | ((wchar & 0xfc0) >> 6);
117 *s = 0x80 | (wchar & 0x3f);
118 return ret + 3;
119 }
120 if (wchar >= (uint32_t) 0x10000 && wchar <= (uint32_t) 0x10ffff)
121 {
122 *s++ = 0xf0 | ((wchar & 0x1c0000) >> 18);
123 *s++ = 0x80 | ((wchar & 0x3f000) >> 12);
124 *s++ = 0x80 | ((wchar & 0xfc0) >> 6);
125 *s = 0x80 | (wchar & 0x3f);
126 return 4;
127 }
128
129 _REENT_ERRNO(r) = EILSEQ;
130 return -1;
131 }
132
133 /* Cygwin defines its own doublebyte charset conversion functions
134 because the underlying OS requires wchar_t == UTF-16. */
135 #ifndef __CYGWIN__
136 int
__sjis_wctomb(char * s,wchar_t _wchar,mbstate_t * state)137 __sjis_wctomb (
138 char *s,
139 wchar_t _wchar,
140 mbstate_t *state)
141 {
142 wint_t wchar = _wchar;
143
144 unsigned char char2 = (unsigned char)wchar;
145 unsigned char char1 = (unsigned char)(wchar >> 8);
146
147 (void) state;
148 if (s == NULL)
149 return 0; /* not state-dependent */
150
151 if (char1 != 0x00)
152 {
153 /* first byte is non-zero..validate multi-byte char */
154 if (_issjis1(char1) && _issjis2(char2))
155 {
156 *s++ = (char)char1;
157 *s = (char)char2;
158 return 2;
159 }
160 else
161 {
162 _REENT_ERRNO(r) = EILSEQ;
163 return -1;
164 }
165 }
166 *s = (char) wchar;
167 return 1;
168 }
169
170 int
__eucjp_wctomb(char * s,wchar_t _wchar,mbstate_t * state)171 __eucjp_wctomb (
172 char *s,
173 wchar_t _wchar,
174 mbstate_t *state)
175 {
176 wint_t wchar = _wchar;
177 unsigned char char2 = (unsigned char)wchar;
178 unsigned char char1 = (unsigned char)(wchar >> 8);
179
180 (void) state;
181 if (s == NULL)
182 return 0; /* not state-dependent */
183
184 if (char1 != 0x00)
185 {
186 /* first byte is non-zero..validate multi-byte char */
187 if (_iseucjp1 (char1) && _iseucjp2 (char2))
188 {
189 *s++ = (char)char1;
190 *s = (char)char2;
191 return 2;
192 }
193 else if (_iseucjp2 (char1) && _iseucjp2 (char2 | 0x80))
194 {
195 *s++ = (char)0x8f;
196 *s++ = (char)char1;
197 *s = (char)(char2 | 0x80);
198 return 3;
199 }
200 else
201 {
202 _REENT_ERRNO(r) = EILSEQ;
203 return -1;
204 }
205 }
206 *s = (char) wchar;
207 return 1;
208 }
209
210 int
__jis_wctomb(char * s,wchar_t _wchar,mbstate_t * state)211 __jis_wctomb (
212 char *s,
213 wchar_t _wchar,
214 mbstate_t *state)
215 {
216 wint_t wchar = _wchar;
217 int cnt = 0;
218 unsigned char char2 = (unsigned char)wchar;
219 unsigned char char1 = (unsigned char)(wchar >> 8);
220
221 if (s == NULL)
222 return 1; /* state-dependent */
223
224 if (char1 != 0x00)
225 {
226 /* first byte is non-zero..validate multi-byte char */
227 if (_isjis (char1) && _isjis (char2))
228 {
229 if (state->__state == 0)
230 {
231 /* must switch from ASCII to JIS state */
232 state->__state = 1;
233 *s++ = ESC_CHAR;
234 *s++ = '$';
235 *s++ = 'B';
236 cnt = 3;
237 }
238 *s++ = (char)char1;
239 *s = (char)char2;
240 return cnt + 2;
241 }
242 _REENT_ERRNO(r) = EILSEQ;
243 return -1;
244 }
245 if (state->__state != 0)
246 {
247 /* must switch from JIS to ASCII state */
248 state->__state = 0;
249 *s++ = ESC_CHAR;
250 *s++ = '(';
251 *s++ = 'B';
252 cnt = 3;
253 }
254 *s = (char)char2;
255 return cnt + 1;
256 }
257 #endif /* !__CYGWIN__ */
258
259 #ifdef _MB_EXTENDED_CHARSETS_ISO
260 static int
___iso_wctomb(char * s,wchar_t _wchar,int iso_idx,mbstate_t * state)261 ___iso_wctomb (char *s, wchar_t _wchar, int iso_idx,
262 mbstate_t *state)
263 {
264 wint_t wchar = _wchar;
265
266 if (s == NULL)
267 return 0;
268
269 /* wchars <= 0x9f translate to all ISO charsets directly. */
270 if (wchar >= 0xa0)
271 {
272 if (iso_idx >= 0)
273 {
274 unsigned char mb;
275
276 for (mb = 0; mb < 0x60; ++mb)
277 if (__iso_8859_conv[iso_idx][mb] == wchar)
278 {
279 *s = (char) (mb + 0xa0);
280 return 1;
281 }
282 _REENT_ERRNO(r) = EILSEQ;
283 return -1;
284 }
285 }
286
287 if ((size_t)wchar >= 0x100)
288 {
289 _REENT_ERRNO(r) = EILSEQ;
290 return -1;
291 }
292
293 *s = (char) wchar;
294 return 1;
295 }
296
__iso_8859_1_wctomb(char * s,wchar_t _wchar,mbstate_t * state)297 int __iso_8859_1_wctomb (char *s, wchar_t _wchar,
298 mbstate_t *state)
299 {
300 return ___iso_wctomb (s, _wchar, -1, state);
301 }
302
__iso_8859_2_wctomb(char * s,wchar_t _wchar,mbstate_t * state)303 int __iso_8859_2_wctomb (char *s, wchar_t _wchar,
304 mbstate_t *state)
305 {
306 return ___iso_wctomb (s, _wchar, 0, state);
307 }
308
__iso_8859_3_wctomb(char * s,wchar_t _wchar,mbstate_t * state)309 int __iso_8859_3_wctomb (char *s, wchar_t _wchar,
310 mbstate_t *state)
311 {
312 return ___iso_wctomb (s, _wchar, 1, state);
313 }
314
__iso_8859_4_wctomb(char * s,wchar_t _wchar,mbstate_t * state)315 int __iso_8859_4_wctomb (char *s, wchar_t _wchar,
316 mbstate_t *state)
317 {
318 return ___iso_wctomb (s, _wchar, 2, state);
319 }
320
__iso_8859_5_wctomb(char * s,wchar_t _wchar,mbstate_t * state)321 int __iso_8859_5_wctomb (char *s, wchar_t _wchar,
322 mbstate_t *state)
323 {
324 return ___iso_wctomb (s, _wchar, 3, state);
325 }
326
__iso_8859_6_wctomb(char * s,wchar_t _wchar,mbstate_t * state)327 int __iso_8859_6_wctomb (char *s, wchar_t _wchar,
328 mbstate_t *state)
329 {
330 return ___iso_wctomb (s, _wchar, 4, state);
331 }
332
__iso_8859_7_wctomb(char * s,wchar_t _wchar,mbstate_t * state)333 int __iso_8859_7_wctomb (char *s, wchar_t _wchar,
334 mbstate_t *state)
335 {
336 return ___iso_wctomb (s, _wchar, 5, state);
337 }
338
__iso_8859_8_wctomb(char * s,wchar_t _wchar,mbstate_t * state)339 int __iso_8859_8_wctomb (char *s, wchar_t _wchar,
340 mbstate_t *state)
341 {
342 return ___iso_wctomb (s, _wchar, 6, state);
343 }
344
__iso_8859_9_wctomb(char * s,wchar_t _wchar,mbstate_t * state)345 int __iso_8859_9_wctomb (char *s, wchar_t _wchar,
346 mbstate_t *state)
347 {
348 return ___iso_wctomb (s, _wchar, 7, state);
349 }
350
__iso_8859_10_wctomb(char * s,wchar_t _wchar,mbstate_t * state)351 int __iso_8859_10_wctomb (char *s, wchar_t _wchar,
352 mbstate_t *state)
353 {
354 return ___iso_wctomb (s, _wchar, 8, state);
355 }
356
__iso_8859_11_wctomb(char * s,wchar_t _wchar,mbstate_t * state)357 int __iso_8859_11_wctomb (char *s, wchar_t _wchar,
358 mbstate_t *state)
359 {
360 return ___iso_wctomb (s, _wchar, 9, state);
361 }
362
__iso_8859_13_wctomb(char * s,wchar_t _wchar,mbstate_t * state)363 int __iso_8859_13_wctomb (char *s, wchar_t _wchar,
364 mbstate_t *state)
365 {
366 return ___iso_wctomb (s, _wchar, 10, state);
367 }
368
__iso_8859_14_wctomb(char * s,wchar_t _wchar,mbstate_t * state)369 int __iso_8859_14_wctomb (char *s, wchar_t _wchar,
370 mbstate_t *state)
371 {
372 return ___iso_wctomb (s, _wchar, 11, state);
373 }
374
__iso_8859_15_wctomb(char * s,wchar_t _wchar,mbstate_t * state)375 int __iso_8859_15_wctomb (char *s, wchar_t _wchar,
376 mbstate_t *state)
377 {
378 return ___iso_wctomb (s, _wchar, 12, state);
379 }
380
__iso_8859_16_wctomb(char * s,wchar_t _wchar,mbstate_t * state)381 int __iso_8859_16_wctomb (char *s, wchar_t _wchar,
382 mbstate_t *state)
383 {
384 return ___iso_wctomb (s, _wchar, 13, state);
385 }
386
387 static wctomb_p __iso_8859_wctomb[17] = {
388 NULL,
389 __iso_8859_1_wctomb,
390 __iso_8859_2_wctomb,
391 __iso_8859_3_wctomb,
392 __iso_8859_4_wctomb,
393 __iso_8859_5_wctomb,
394 __iso_8859_6_wctomb,
395 __iso_8859_7_wctomb,
396 __iso_8859_8_wctomb,
397 __iso_8859_9_wctomb,
398 __iso_8859_10_wctomb,
399 __iso_8859_11_wctomb,
400 NULL, /* No ISO 8859-12 */
401 __iso_8859_13_wctomb,
402 __iso_8859_14_wctomb,
403 __iso_8859_15_wctomb,
404 __iso_8859_16_wctomb
405 };
406
407 /* val *MUST* be valid! All checks for validity are supposed to be
408 performed before calling this function. */
409 wctomb_p
__iso_wctomb(int val)410 __iso_wctomb (int val)
411 {
412 return __iso_8859_wctomb[val];
413 }
414 #endif /* _MB_EXTENDED_CHARSETS_ISO */
415
416 #ifdef _MB_EXTENDED_CHARSETS_WINDOWS
417 static int
___cp_wctomb(char * s,wchar_t _wchar,int cp_idx,mbstate_t * state)418 ___cp_wctomb (char *s, wchar_t _wchar, int cp_idx,
419 mbstate_t *state)
420 {
421 wint_t wchar = _wchar;
422
423 if (s == NULL)
424 return 0;
425
426 if (wchar >= 0x80)
427 {
428 if (cp_idx >= 0)
429 {
430 unsigned char mb;
431
432 for (mb = 0; mb < 0x80; ++mb)
433 if (__cp_conv[cp_idx][mb] == wchar)
434 {
435 *s = (char) (mb + 0x80);
436 return 1;
437 }
438 _REENT_ERRNO(r) = EILSEQ;
439 return -1;
440 }
441 }
442
443 if ((size_t)wchar >= 0x100)
444 {
445 _REENT_ERRNO(r) = EILSEQ;
446 return -1;
447 }
448
449 *s = (char) wchar;
450 return 1;
451 }
452
453 static int
__cp_437_wctomb(char * s,wchar_t _wchar,mbstate_t * state)454 __cp_437_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
455 {
456 return ___cp_wctomb (s, _wchar, 0, state);
457 }
458
459 static int
__cp_720_wctomb(char * s,wchar_t _wchar,mbstate_t * state)460 __cp_720_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
461 {
462 return ___cp_wctomb (s, _wchar, 1, state);
463 }
464
465 static int
__cp_737_wctomb(char * s,wchar_t _wchar,mbstate_t * state)466 __cp_737_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
467 {
468 return ___cp_wctomb (s, _wchar, 2, state);
469 }
470
471 static int
__cp_775_wctomb(char * s,wchar_t _wchar,mbstate_t * state)472 __cp_775_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
473 {
474 return ___cp_wctomb (s, _wchar, 3, state);
475 }
476
477 static int
__cp_850_wctomb(char * s,wchar_t _wchar,mbstate_t * state)478 __cp_850_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
479 {
480 return ___cp_wctomb (s, _wchar, 4, state);
481 }
482
483 static int
__cp_852_wctomb(char * s,wchar_t _wchar,mbstate_t * state)484 __cp_852_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
485 {
486 return ___cp_wctomb (s, _wchar, 5, state);
487 }
488
489 static int
__cp_855_wctomb(char * s,wchar_t _wchar,mbstate_t * state)490 __cp_855_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
491 {
492 return ___cp_wctomb (s, _wchar, 6, state);
493 }
494
495 static int
__cp_857_wctomb(char * s,wchar_t _wchar,mbstate_t * state)496 __cp_857_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
497 {
498 return ___cp_wctomb (s, _wchar, 7, state);
499 }
500
501 static int
__cp_858_wctomb(char * s,wchar_t _wchar,mbstate_t * state)502 __cp_858_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
503 {
504 return ___cp_wctomb (s, _wchar, 8, state);
505 }
506
507 static int
__cp_862_wctomb(char * s,wchar_t _wchar,mbstate_t * state)508 __cp_862_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
509 {
510 return ___cp_wctomb (s, _wchar, 9, state);
511 }
512
513 static int
__cp_866_wctomb(char * s,wchar_t _wchar,mbstate_t * state)514 __cp_866_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
515 {
516 return ___cp_wctomb (s, _wchar, 10, state);
517 }
518
519 static int
__cp_874_wctomb(char * s,wchar_t _wchar,mbstate_t * state)520 __cp_874_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
521 {
522 return ___cp_wctomb (s, _wchar, 11, state);
523 }
524
525 static int
__cp_1125_wctomb(char * s,wchar_t _wchar,mbstate_t * state)526 __cp_1125_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
527 {
528 return ___cp_wctomb (s, _wchar, 12, state);
529 }
530
531 static int
__cp_1250_wctomb(char * s,wchar_t _wchar,mbstate_t * state)532 __cp_1250_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
533 {
534 return ___cp_wctomb (s, _wchar, 13, state);
535 }
536
537 static int
__cp_1251_wctomb(char * s,wchar_t _wchar,mbstate_t * state)538 __cp_1251_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
539 {
540 return ___cp_wctomb (s, _wchar, 14, state);
541 }
542
543 static int
__cp_1252_wctomb(char * s,wchar_t _wchar,mbstate_t * state)544 __cp_1252_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
545 {
546 return ___cp_wctomb (s, _wchar, 15, state);
547 }
548
549 static int
__cp_1253_wctomb(char * s,wchar_t _wchar,mbstate_t * state)550 __cp_1253_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
551 {
552 return ___cp_wctomb (s, _wchar, 16, state);
553 }
554
555 static int
__cp_1254_wctomb(char * s,wchar_t _wchar,mbstate_t * state)556 __cp_1254_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
557 {
558 return ___cp_wctomb (s, _wchar, 17, state);
559 }
560
561 static int
__cp_1255_wctomb(char * s,wchar_t _wchar,mbstate_t * state)562 __cp_1255_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
563 {
564 return ___cp_wctomb (s, _wchar, 18, state);
565 }
566
567 static int
__cp_1256_wctomb(char * s,wchar_t _wchar,mbstate_t * state)568 __cp_1256_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
569 {
570 return ___cp_wctomb (s, _wchar, 19, state);
571 }
572
573 static int
__cp_1257_wctomb(char * s,wchar_t _wchar,mbstate_t * state)574 __cp_1257_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
575 {
576 return ___cp_wctomb (s, _wchar, 20, state);
577 }
578
579 static int
__cp_1258_wctomb(char * s,wchar_t _wchar,mbstate_t * state)580 __cp_1258_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
581 {
582 return ___cp_wctomb (s, _wchar, 21, state);
583 }
584
585 static int
__cp_20866_wctomb(char * s,wchar_t _wchar,mbstate_t * state)586 __cp_20866_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
587 {
588 return ___cp_wctomb (s, _wchar, 22, state);
589 }
590
591 static int
__cp_21866_wctomb(char * s,wchar_t _wchar,mbstate_t * state)592 __cp_21866_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
593 {
594 return ___cp_wctomb (s, _wchar, 23, state);
595 }
596
597 static int
__cp_101_wctomb(char * s,wchar_t _wchar,mbstate_t * state)598 __cp_101_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
599 {
600 return ___cp_wctomb (s, _wchar, 24, state);
601 }
602
603 static int
__cp_102_wctomb(char * s,wchar_t _wchar,mbstate_t * state)604 __cp_102_wctomb (char *s, wchar_t _wchar, mbstate_t *state)
605 {
606 return ___cp_wctomb (s, _wchar, 25, state);
607 }
608
609 static int
__cp_103_wctomb(struct _reent * r,char * s,wchar_t _wchar,mbstate_t * state)610 __cp_103_wctomb (struct _reent *r, char *s, wchar_t _wchar, mbstate_t *state)
611 {
612 return ___cp_wctomb (r, s, _wchar, 26, state);
613 }
614
615 static wctomb_p __cp_xxx_wctomb[27] = {
616 __cp_437_wctomb,
617 __cp_720_wctomb,
618 __cp_737_wctomb,
619 __cp_775_wctomb,
620 __cp_850_wctomb,
621 __cp_852_wctomb,
622 __cp_855_wctomb,
623 __cp_857_wctomb,
624 __cp_858_wctomb,
625 __cp_862_wctomb,
626 __cp_866_wctomb,
627 __cp_874_wctomb,
628 __cp_1125_wctomb,
629 __cp_1250_wctomb,
630 __cp_1251_wctomb,
631 __cp_1252_wctomb,
632 __cp_1253_wctomb,
633 __cp_1254_wctomb,
634 __cp_1255_wctomb,
635 __cp_1256_wctomb,
636 __cp_1257_wctomb,
637 __cp_1258_wctomb,
638 __cp_20866_wctomb,
639 __cp_21866_wctomb,
640 __cp_101_wctomb,
641 __cp_102_wctomb,
642 __cp_103_wctomb,
643 };
644
645 /* val *MUST* be valid! All checks for validity are supposed to be
646 performed before calling this function. */
647 wctomb_p
__cp_wctomb(int val)648 __cp_wctomb (int val)
649 {
650 return __cp_xxx_wctomb[__cp_val_index (val)];
651 }
652 #endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
653 #endif /* _MB_CAPABLE */
654