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 "gdkprivate.h"
39 /* If this variable is FALSE, it indicates that we should
40 * avoid trying to use multibyte conversion functions and
41 * assume everything is 1-byte per character
43 static gboolean gdk_use_mb;
46 *--------------------------------------------------------------
55 *--------------------------------------------------------------
62 gchar *current_locale;
66 if (!setlocale (LC_ALL,""))
67 g_warning ("locale not supported by C library");
69 current_locale = setlocale (LC_ALL, NULL);
74 GDK_NOTE (XIM, g_message ("%s multi-byte string functions.",
75 gdk_use_mb ? "Using" : "Not using"));
77 return current_locale;
81 gdk_im_begin (GdkIC *ic, GdkWindow* window)
91 gdk_im_decide_style (GdkIMStyle supported_style)
93 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
97 gdk_im_set_best_style (GdkIMStyle style)
99 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
109 gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask)
115 gdk_ic_destroy (GdkIC *ic)
120 gdk_ic_get_style (GdkIC *ic)
122 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
126 gdk_ic_set_values (GdkIC *ic, ...)
131 gdk_ic_get_values (GdkIC *ic, ...)
136 gdk_ic_set_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
142 gdk_ic_get_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
148 gdk_ic_get_events (GdkIC *ic)
156 * Returns a multi-byte string converted from the specified array
157 * of wide characters. The string is newly allocated. The array of
158 * wide characters must be null-terminated. If the conversion is
159 * failed, it returns NULL.
162 gdk_wcstombs (const GdkWChar *src)
171 for (wcsl = 0; src[wcsl]; wcsl++)
173 src_alt = g_new (wchar_t, wcsl+1);
174 for (i = wcsl; i >= 0; i--)
176 mbsl = WideCharToMultiByte (CP_ACP, 0, src_alt, wcsl,
177 NULL, 0, NULL, NULL);
178 mbstr = g_new (guchar, mbsl + 1);
179 if (!WideCharToMultiByte (CP_ACP, 0, src_alt, wcsl,
180 mbstr, mbsl, NULL, NULL))
182 g_warning ("gdk_wcstombs: WideCharToMultiByte failed");
196 while (src[length] != 0)
199 mbstr = g_new (gchar, length + 1);
201 for (i=0; i<length+1; i++)
212 * Converts the specified string into wide characters, and, returns the
213 * number of wide characters written. The string 'src' must be
214 * null-terminated. If the conversion is failed, it returns -1.
217 gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
224 wcsl = MultiByteToWideChar (CP_ACP, 0, src, -1, NULL, 0);
225 wcstr = g_new (wchar_t, wcsl + 1);
226 if (!MultiByteToWideChar (CP_ACP, 0, src, -1, wcstr, wcsl))
228 g_warning ("gdk_mbstowcs: MultiByteToWideChar failed");
234 for (i = 0; i < wcsl; i++)
243 for (i=0; i<dest_max && src[i]; i++)