(Fcharset_name): Define `byte_offset' in non-UTF-2000 configuration.
[chise/xemacs-chise.git-] / src / input-method-xfs.c
1 /* input-method-xfs.c provides just only locale initialize
2    for non Motif people. (stoled from input-method-xlib.c)
3    Why I made this code is to initialize X locale environment for
4    the purpose of use XFontSet correctly in lwlib/xlwmenu.c.
5    And this code donot provides input methods under Xlib while they
6    prefer to use Canna, Wnn, skk or something like that.
7    This code has been tested on FreeBSD 2.2.1 and Solaris2.5.
8
9    Copyright (C) 1997 Kazuyuki IENAGA.
10
11 This file is a part of XEmacs.
12
13 XEmacs is free software; you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by the
15 Free Software Foundation; either version 2, or (at your option) any
16 later version.
17
18 XEmacs is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with XEmacs; see the file COPYING.  If not, write to
25 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.  */
27
28 #include <config.h>
29 #include <X11/Xlocale.h>        /* More portable than <locale.h> ? */
30 #include "lisp.h"
31 #include "frame.h"
32 #include "device.h"
33 #include "window.h"
34 #include "buffer.h"
35 #include "console-x.h"
36 #include "EmacsFrame.h"
37 #include "events.h"
38
39 #ifdef USE_XFONTSET
40 void
41 Initialize_Locale (void)
42 {
43   char *locale;
44
45   /* dverna - Nov. 98: ### DON'T DO THIS !!! The default XtLanguageProc
46      routine calls setlocale(LC_ALL, lang) which fucks up our lower-level
47      locale management, and especially the value of LC_NUMERIC. Anyway, since
48      at this point, we don't know yet whether we're gonna need an X11 frame,
49      we should really do it manually and not use Xlib's dumb default routine */
50   /*XtSetLanguageProc (NULL, (XtLanguageProc) NULL, NULL);*/
51   if ((locale = setlocale (LC_ALL, "")) == NULL)
52     {
53       stderr_out ("Can't set locale.\n");
54       stderr_out ("Using C locale instead.\n");
55       putenv ("LANG=C");
56       putenv ("LC_ALL=C");
57       if ((locale = setlocale (LC_ALL, "C")) == NULL)
58         {
59           stderr_out ("Can't even set locale to `C'!\n");
60           return;
61         }
62     }
63
64   if (!XSupportsLocale ())
65     {
66       stderr_out ("X Windows does not support locale `%s'\n", locale);
67       stderr_out ("Using C Locale instead\n");
68       putenv ("LANG=C");
69       putenv ("LC_ALL=C");
70       if ((locale = setlocale (LC_ALL, "C")) == NULL)
71         {
72           stderr_out ("Can't even set locale to `C'!\n");
73           return;
74         }
75       if (!XSupportsLocale ())
76         {
77           stderr_out ("X Windows does not even support locale `C'!\n");
78           return;
79         }
80     }
81
82   setlocale(LC_NUMERIC, "C");
83   setlocale(LC_CTYPE, ""); /* take back CTYPE to previous state */
84   
85   if (XSetLocaleModifiers ("") == NULL)
86     {
87       stderr_out ("XSetLocaleModifiers(\"\") failed\n");
88       stderr_out ("Check the value of the XMODIFIERS environment variable.\n");
89     }
90 }
91 #endif /* USE_XFONTSET */