OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdlib/] [wctomb.c] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
/*
2
FUNCTION
3
<<wctomb>>---minimal wide char to multibyte converter
4
 
5
INDEX
6
        wctomb
7
 
8
ANSI_SYNOPSIS
9
        #include <stdlib.h>
10
        int wctomb(char *<[s]>, wchar_t <[wchar]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <stdlib.h>
14
        int wctomb(<[s]>, <[wchar]>)
15
        char *<[s]>;
16
        wchar_t <[wchar]>;
17
 
18
DESCRIPTION
19
When MB_CAPABLE is not defined, this is a minimal ANSI-conforming
20
implementation of <<wctomb>>.  The
21
only ``wide characters'' recognized are single bytes,
22
and they are ``converted'' to themselves.
23
 
24
When MB_CAPABLE is defined, this routine calls <<_wctomb_r>> to perform
25
the conversion, passing a state variable to allow state dependent
26
decoding.  The result is based on the locale setting which may
27
be restricted to a defined set of locales.
28
 
29
Each call to <<wctomb>> modifies <<*<[s]>>> unless <[s]> is a null
30
pointer or MB_CAPABLE is defined and <[wchar]> is invalid.
31
 
32
RETURNS
33
This implementation of <<wctomb>> returns <<0>> if
34
<[s]> is <<NULL>>; it returns <<-1>> if MB_CAPABLE is enabled
35
and the wchar is not a valid multi-byte character, it returns <<1>>
36
if MB_CAPABLE is not defined or the wchar is in reality a single
37
byte character, otherwise it returns the number of bytes in the
38
multi-byte character.
39
 
40
PORTABILITY
41
<<wctomb>> is required in the ANSI C standard.  However, the precise
42
effects vary with the locale.
43
 
44
<<wctomb>> requires no supporting OS subroutines.
45
*/
46
 
47
#ifndef _REENT_ONLY
48
 
49
#include <stdlib.h>
50
 
51
int
52
_DEFUN (wctomb, (s, wchar),
53
        char *s _AND
54
        wchar_t wchar)
55
{
56
#ifdef MB_CAPABLE
57
        static int state;
58
 
59
        return _wctomb_r (_REENT, s, wchar, &state);
60
#else /* not MB_CAPABLE */
61
        if (s == NULL)
62
                return 0;
63
 
64
        *s = (char) wchar;
65
        return 1;
66
#endif /* not MB_CAPABLE */
67
}
68
 
69
#endif /* !_REENT_ONLY */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.