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

Subversion Repositories or1k

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

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

Line No. Rev Author Line
1 39 lampret
/*
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
#include <stdlib.h>
48
int
49
_DEFUN (wctomb, (s, wchar),
50
        char *s _AND
51
        wchar_t wchar)
52
{
53
#ifdef MB_CAPABLE
54
        static int state;
55
 
56
        return _wctomb_r (_REENT, s, wchar, &state);
57
#else /* not MB_CAPABLE */
58
        if (s == NULL)
59
                return 0;
60
 
61
        *s = (char) wchar;
62
        return 1;
63
#endif /* not MB_CAPABLE */
64
}

powered by: WebSVN 2.1.0

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