upload tizen2.0 source
[framework/uifw/xorg/lib/libxaw.git] / src / XawI18n.c
1 /* Copyright 1991 NCR Corporation - Dayton, Ohio, USA */
2
3 /*
4  * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
5  *                      and Nippon Telegraph and Telephone Corporation
6  *
7  * Permission to use, copy, modify, distribute, and sell this software and its
8  * documentation for any purpose is hereby granted without fee, provided that
9  * the above copyright notice appear in all copies and that both that
10  * copyright notice and this permission notice appear in supporting
11  * documentation, and that the names of OMRON, NTT Software, and NTT
12  * not be used in advertising or publicity pertaining to distribution of the
13  * software without specific, written prior permission. OMRON, NTT Software,
14  * and NTT make no representations about the suitability of this
15  * software for any purpose.  It is provided "as is" without express or
16  * implied warranty.
17  *
18  * OMRON, NTT SOFTWARE, AND NTT, DISCLAIM ALL WARRANTIES WITH REGARD
19  * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
20  * AND FITNESS, IN NO EVENT SHALL OMRON, NTT SOFTWARE, OR NTT BE
21  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
23  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
24  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25  *
26  *      Author: Li Yuhong       OMRON Corporation
27  */
28
29 /*
30
31 Copyright 1991, 1994, 1998  The Open Group
32
33 Permission to use, copy, modify, distribute, and sell this software and its
34 documentation for any purpose is hereby granted without fee, provided that
35 the above copyright notice appear in all copies and that both that
36 copyright notice and this permission notice appear in supporting
37 documentation.
38
39 The above copyright notice and this permission notice shall be included in
40 all copies or substantial portions of the Software.
41
42 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
45 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
46 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
47 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
48
49 Except as contained in this notice, the name of The Open Group shall not be
50 used in advertising or otherwise to promote the sale, use or other dealings
51 in this Software without prior written authorization from The Open Group.
52
53 */
54
55 #ifdef HAVE_CONFIG_H
56 #include <config.h>
57 #endif
58 #include <X11/IntrinsicP.h>
59 #include "XawI18n.h"
60
61 wchar_t
62 #if NeedWidePrototypes
63 _Xaw_atowc(int c)
64 #else
65 _Xaw_atowc(unsigned char c)
66 #endif
67 {
68     wchar_t  wc;
69     char str[2];
70
71     str[0] = c;
72     str[1] = '\0';
73
74     mbtowc(&wc, str, 1);
75
76     return (wc);
77 }
78
79 #ifdef NCR
80 int
81 _Xaw_iswspace(wchar_t w)
82 {
83     int ret = 0;
84     wchar_t s = _Xaw_atowc(' ');
85
86     if (s == w)
87         ret = 1;
88
89   return (ret);
90 }
91 #endif
92
93 int
94 _Xaw_iswalnum(wchar_t ch)
95 {
96 #ifdef HAVE_ISWALNUM
97     return iswalnum(ch);
98 #else
99     unsigned char mb[MB_LEN_MAX];
100
101     wctomb((char*)mb, ch);
102
103     return (isalnum(*mb));
104 #endif
105 }