XawI18n.c revision 7a84e134
17a84e134Smrg/* $Xorg: XawI18n.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */ 27a84e134Smrg 37a84e134Smrg/* Copyright 1991 NCR Corporation - Dayton, Ohio, USA */ 47a84e134Smrg 57a84e134Smrg/* 67a84e134Smrg * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation, 77a84e134Smrg * and Nippon Telegraph and Telephone Corporation 87a84e134Smrg * 97a84e134Smrg * Permission to use, copy, modify, distribute, and sell this software and its 107a84e134Smrg * documentation for any purpose is hereby granted without fee, provided that 117a84e134Smrg * the above copyright notice appear in all copies and that both that 127a84e134Smrg * copyright notice and this permission notice appear in supporting 137a84e134Smrg * documentation, and that the names of OMRON, NTT Software, and NTT 147a84e134Smrg * not be used in advertising or publicity pertaining to distribution of the 157a84e134Smrg * software without specific, written prior permission. OMRON, NTT Software, 167a84e134Smrg * and NTT make no representations about the suitability of this 177a84e134Smrg * software for any purpose. It is provided "as is" without express or 187a84e134Smrg * implied warranty. 197a84e134Smrg * 207a84e134Smrg * OMRON, NTT SOFTWARE, AND NTT, DISCLAIM ALL WARRANTIES WITH REGARD 217a84e134Smrg * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 227a84e134Smrg * AND FITNESS, IN NO EVENT SHALL OMRON, NTT SOFTWARE, OR NTT BE 237a84e134Smrg * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 247a84e134Smrg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 257a84e134Smrg * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 267a84e134Smrg * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 277a84e134Smrg * 287a84e134Smrg * Author: Li Yuhong OMRON Corporation 297a84e134Smrg */ 307a84e134Smrg 317a84e134Smrg/* 327a84e134Smrg 337a84e134SmrgCopyright 1991, 1994, 1998 The Open Group 347a84e134Smrg 357a84e134SmrgPermission to use, copy, modify, distribute, and sell this software and its 367a84e134Smrgdocumentation for any purpose is hereby granted without fee, provided that 377a84e134Smrgthe above copyright notice appear in all copies and that both that 387a84e134Smrgcopyright notice and this permission notice appear in supporting 397a84e134Smrgdocumentation. 407a84e134Smrg 417a84e134SmrgThe above copyright notice and this permission notice shall be included in 427a84e134Smrgall copies or substantial portions of the Software. 437a84e134Smrg 447a84e134SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 457a84e134SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 467a84e134SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 477a84e134SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 487a84e134SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 497a84e134SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 507a84e134Smrg 517a84e134SmrgExcept as contained in this notice, the name of The Open Group shall not be 527a84e134Smrgused in advertising or otherwise to promote the sale, use or other dealings 537a84e134Smrgin this Software without prior written authorization from The Open Group. 547a84e134Smrg 557a84e134Smrg*/ 567a84e134Smrg/* $XFree86: xc/lib/Xaw/XawI18n.c,v 1.7 2001/01/17 19:42:36 dawes Exp $ */ 577a84e134Smrg 587a84e134Smrg#ifdef HAVE_CONFIG_H 597a84e134Smrg#include <config.h> 607a84e134Smrg#endif 617a84e134Smrg#include <X11/IntrinsicP.h> 627a84e134Smrg#include "XawI18n.h" 637a84e134Smrg 647a84e134Smrgwchar_t 657a84e134Smrg#if NeedWidePrototypes 667a84e134Smrg_Xaw_atowc(int c) 677a84e134Smrg#else 687a84e134Smrg_Xaw_atowc(unsigned char c) 697a84e134Smrg#endif 707a84e134Smrg{ 717a84e134Smrg wchar_t wc; 727a84e134Smrg char str[2]; 737a84e134Smrg 747a84e134Smrg str[0] = c; 757a84e134Smrg str[1] = '\0'; 767a84e134Smrg 777a84e134Smrg mbtowc(&wc, str, 1); 787a84e134Smrg 797a84e134Smrg return (wc); 807a84e134Smrg} 817a84e134Smrg 827a84e134Smrg#ifdef NCR 837a84e134Smrgint 847a84e134Smrg_Xaw_iswspace(wchar_t w) 857a84e134Smrg{ 867a84e134Smrg int ret = 0; 877a84e134Smrg wchar_t s = _Xaw_atowc(' '); 887a84e134Smrg 897a84e134Smrg if (s == w) 907a84e134Smrg ret = 1; 917a84e134Smrg 927a84e134Smrg return (ret); 937a84e134Smrg} 947a84e134Smrg#endif 957a84e134Smrg 967a84e134Smrgint 977a84e134Smrg_Xaw_iswalnum(wchar_t ch) 987a84e134Smrg{ 997a84e134Smrg#ifdef HAVE_ISWALNUM 1007a84e134Smrg return iswalnum(ch); 1017a84e134Smrg#else 1027a84e134Smrg unsigned char mb[MB_LEN_MAX]; 1037a84e134Smrg 1047a84e134Smrg wctomb((char*)mb, ch); 1057a84e134Smrg 1067a84e134Smrg return (isalnum(*mb)); 1077a84e134Smrg#endif 1087a84e134Smrg} 109