1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
35 #include <gdk/gdki18n.h>
38 /* If this variable is FALSE, it indicates that we should
39 * avoid trying to use multibyte conversion functions and
40 * assume everything is 1-byte per character
42 static gboolean gdk_use_mb;
45 *--------------------------------------------------------------
54 *--------------------------------------------------------------
61 gchar *current_locale;
65 if (!setlocale (LC_ALL,""))
66 g_warning ("locale not supported by C library");
68 current_locale = setlocale (LC_ALL, NULL);
73 GDK_NOTE (XIM, g_message ("%s multi-byte string functions.",
74 gdk_use_mb ? "Using" : "Not using"));
76 return current_locale;
80 gdk_im_begin (GdkIC *ic, GdkWindow* window)
90 gdk_im_decide_style (GdkIMStyle supported_style)
92 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
96 gdk_im_set_best_style (GdkIMStyle style)
98 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
108 gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask)
114 gdk_ic_destroy (GdkIC *ic)
119 gdk_ic_get_style (GdkIC *ic)
121 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
125 gdk_ic_set_values (GdkIC *ic, ...)
130 gdk_ic_get_values (GdkIC *ic, ...)
135 gdk_ic_set_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
141 gdk_ic_get_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
147 gdk_ic_get_events (GdkIC *ic)
155 * Returns a multi-byte string converted from the specified array
156 * of wide characters. The string is newly allocated. The array of
157 * wide characters must be null-terminated. If the conversion is
158 * failed, it returns NULL.
161 gdk_wcstombs (const GdkWChar *src)
170 for (wcsl = 0; src[wcsl]; wcsl++)
172 src_alt = g_new (wchar_t, wcsl+1);
173 for (i = wcsl; i >= 0; i--)
175 mbsl = WideCharToMultiByte (CP_OEMCP, 0, src_alt, wcsl,
176 NULL, 0, NULL, NULL);
177 mbstr = g_new (guchar, mbsl + 1);
178 if (!WideCharToMultiByte (CP_OEMCP, 0, src_alt, wcsl,
179 mbstr, mbsl, NULL, NULL))
181 g_warning ("gdk_wcstombs: WideCharToMultiByte failed");
194 while (src[length] != 0)
197 mbstr = g_new (gchar, length + 1);
199 for (i=0; i<length+1; i++)
210 * Converts the specified string into wide characters, and, returns the
211 * number of wide characters written. The string 'src' must be
212 * null-terminated. If the conversion is failed, it returns -1.
215 gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
222 wcsl = MultiByteToWideChar (CP_OEMCP, 0, src, -1, NULL, 0);
223 wcstr = g_new (wchar_t, wcsl);
224 if (!MultiByteToWideChar (CP_OEMCP, 0, src, -1, wcstr, wcsl))
226 g_warning ("gdk_mbstowcs: MultiByteToWideChar failed");
232 for (i = 0; i < wcsl && wcstr[i]; i++)
242 for (i=0; i<dest_max && src[i]; i++)