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