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