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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-newlib/] [newlib-1.17.0/] [newlib/] [libc/] [string/] [wcwidth.c] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 jlechner
/*
2
FUNCTION
3
        <<wcwidth>>---number of column positions of a wide-character code
4
 
5
INDEX
6
        wcwidth
7
 
8
ANSI_SYNOPSIS
9
        #include <wchar.h>
10
        int wcwidth(const wchar_t <[wc]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <wchar.h>
14
        int wcwidth(<[wc]>)
15
        wchar_t *<[wc]>;
16
 
17
DESCRIPTION
18
        The <<wcwidth>> function shall determine the number of column
19
        positions required for the wide character <[wc]>. The application
20
        shall ensure that the value of <[wc]> is a character representable
21
        as a wchar_t, and is a wide-character code corresponding to a
22
        valid character in the current locale.
23
 
24
RETURNS
25
        The <<wcwidth>> function shall either return 0 (if <[wc]> is a null
26
        wide-character code), or return the number of column positions to
27
        be occupied by the wide-character code <[wc]>, or return -1 (if <[wc]>
28
        does not correspond to a printable wide-character code).
29
 
30
        The current implementation of <<wcwidth>> simply sets the width
31
        of all printable characters to 1 since newlib has no character
32
        tables around.
33
 
34
PORTABILITY
35
<<wcwidth>> has been introduced in the Single UNIX Specification Volume 2.
36
<<wcwidth>> has been marked as an extension in the Single UNIX Specification Volume 3.
37
*/
38
 
39
#include <_ansi.h>
40
#include <wchar.h>
41
#include <wctype.h>
42
 
43
int
44
_DEFUN (wcwidth, (wc),
45
        _CONST wchar_t wc)
46
 
47
{
48
  if (iswprint (wc))
49
    return 1;
50
  if (iswcntrl (wc) || wc == L'\0')
51
    return 0;
52
  return -1;
53
}

powered by: WebSVN 2.1.0

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