mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 11:20:12 +00:00
d8b2f46c18
2004-07-07 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text) * gdk/win32/gdkfont-win32.c (gdk_text_extents) * gdk/win32/gdkproperty-win32.c (find_common_locale, gdk_property_change) * gdk/win32/gdkselection-win32.c (gdk_selection_convert): Use g_utf8_to_utf16() instead of the removed _gdk_utf8_to_ucs2() (see below). * gdk/win32/gdkglobals-win32.c * gdk/win32/gdkmain-win32.c (_gdk_windowing_init) * gdk/win3/gdkprivate-win32.h: Add a variable for the TARGETS atom. Initialize it. Declare it. Drop the variable for the COMPOUND_TEXT atom. * gdk/win32/gdkim-win32.c (gdk_wcstombs): Don't return UTF-8. This function is supposed to return the string in the locale's charset and encoding. Use g_convert(). (gdk_mbstowcs): Similarily, don't take an UTF-8 string, but a string in the locale's charset. Use g_convert(). (_gdk_ucs2_to_utf8, _gdk_utf8_to_wcs, _gdk_utf8_to_ucs2): Delete. The UCS-2 functions didn't handle surrogates anyway. Use GLib's UTF-16 functions instead. Windows uses UTF-16. * gdk/win32/gdkprivate-win32.h: Remove declarations of the deleted functions mentioned above. * gdk/win32/gdkproperty-win32.c (gdk_property_change): Use CF_TEXT also if the string is of type STRING, i.e. ISO-8859-1, and the current codepage is 1252, and contains no C1 chars. Accept also UTF8_STRING. * gdk/win32/gdkselection-win32.c (_gdk_selection_property_store): Mark as static. When storing STRING data, convert to Latin-1. (#140537) (gdk_selection_owner_set_for_display): Now that STRING is always ISO-8859-1, use UTF8_STRING when sending the selection request to ourselves. (gdk_selection_convert): Handle also UTF8_STRING. (#140537, John Ehresman) (gdk_text_property_to_text_list_for_display): Make work more like X11 version. Do obey the encoding parameter. (gdk_string_to_compound_text_for_display, gdk_utf8_to_compound_text_for_display): Don't even pretend supporting COMPOUND_TEXT. (gdk_utf8_to_string_target): Convert to ISO-8859-1, like on X11. (sanitize_utf8): Zero-terminate string.
93 lines
2.3 KiB
C
93 lines
2.3 KiB
C
/* GDK - The GIMP Drawing Kit
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
* Copyright (C) 1998-2004 Tor Lillqvist
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
/*
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
* files for a list of changes. These files are distributed with
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <locale.h>
|
|
|
|
#include "gdkpixmap.h"
|
|
#include "gdkinternals.h"
|
|
#include "gdki18n.h"
|
|
#include "gdkwin32.h"
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_set_locale
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gchar*
|
|
gdk_set_locale (void)
|
|
{
|
|
if (!setlocale (LC_ALL, ""))
|
|
g_warning ("locale not supported by C library");
|
|
|
|
return g_win32_getlocale ();
|
|
}
|
|
|
|
gchar *
|
|
gdk_wcstombs (const GdkWChar *src)
|
|
{
|
|
gchar *utf8;
|
|
gchar *retval;
|
|
const gchar *charset;
|
|
|
|
g_get_charset (&charset);
|
|
return g_convert (src, -1, charset, "UCS-4LE", NULL, NULL, NULL);
|
|
}
|
|
|
|
gint
|
|
gdk_mbstowcs (GdkWChar *dest,
|
|
const gchar *src,
|
|
gint dest_max)
|
|
{
|
|
gint retval;
|
|
gsize nwritten;
|
|
gint n_ucs4;
|
|
gunichar *ucs4;
|
|
const gchar *charset;
|
|
|
|
g_get_charset (&charset);
|
|
ucs4 = g_convert (src, -1, "UCS-4LE", charset, NULL, &nwritten, NULL);
|
|
n_ucs4 = nwritten * sizeof (GdkWChar);
|
|
|
|
retval = MIN (dest_max, n_ucs4);
|
|
memmove (dest, ucs4, retval * sizeof (GdkWChar));
|
|
g_free (ucs4);
|
|
|
|
return retval;
|
|
}
|