Use GetACP to get the current ANSI codepage.

2000-12-17  Tor Lillqvist  <tml@iki.fi>

	* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
	the current ANSI codepage.

	* gunicode.h: Add comment that the static string g_get_charset
	sets the parameter to point to should be copied in case the
	charset might be changed later in the program.
This commit is contained in:
Tor Lillqvist 2000-12-17 18:43:57 +00:00 committed by Tor Lillqvist
parent a5f18bb9ba
commit 4f9e04c1d7
13 changed files with 112 additions and 4 deletions

View File

@ -1,3 +1,12 @@
2000-12-17 Tor Lillqvist <tml@iki.fi>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
the current ANSI codepage.
* gunicode.h: Add comment that the static string g_get_charset
sets the parameter to point to should be copied in case the
charset might be changed later in the program.
2000-12-14 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when

View File

@ -1,3 +1,12 @@
2000-12-17 Tor Lillqvist <tml@iki.fi>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
the current ANSI codepage.
* gunicode.h: Add comment that the static string g_get_charset
sets the parameter to point to should be copied in case the
charset might be changed later in the program.
2000-12-14 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when

View File

@ -1,3 +1,12 @@
2000-12-17 Tor Lillqvist <tml@iki.fi>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
the current ANSI codepage.
* gunicode.h: Add comment that the static string g_get_charset
sets the parameter to point to should be copied in case the
charset might be changed later in the program.
2000-12-14 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when

View File

@ -1,3 +1,12 @@
2000-12-17 Tor Lillqvist <tml@iki.fi>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
the current ANSI codepage.
* gunicode.h: Add comment that the static string g_get_charset
sets the parameter to point to should be copied in case the
charset might be changed later in the program.
2000-12-14 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when

View File

@ -1,3 +1,12 @@
2000-12-17 Tor Lillqvist <tml@iki.fi>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
the current ANSI codepage.
* gunicode.h: Add comment that the static string g_get_charset
sets the parameter to point to should be copied in case the
charset might be changed later in the program.
2000-12-14 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when

View File

@ -1,3 +1,12 @@
2000-12-17 Tor Lillqvist <tml@iki.fi>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
the current ANSI codepage.
* gunicode.h: Add comment that the static string g_get_charset
sets the parameter to point to should be copied in case the
charset might be changed later in the program.
2000-12-14 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when

View File

@ -1,3 +1,12 @@
2000-12-17 Tor Lillqvist <tml@iki.fi>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
the current ANSI codepage.
* gunicode.h: Add comment that the static string g_get_charset
sets the parameter to point to should be copied in case the
charset might be changed later in the program.
2000-12-14 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when

View File

@ -1,3 +1,12 @@
2000-12-17 Tor Lillqvist <tml@iki.fi>
* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
the current ANSI codepage.
* gunicode.h: Add comment that the static string g_get_charset
sets the parameter to point to should be copied in case the
charset might be changed later in the program.
2000-12-14 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when

View File

@ -105,7 +105,9 @@ typedef enum
/* Returns TRUE if current locale uses UTF-8 charset. If CHARSET is
* not null, sets *CHARSET to the name of the current locale's
* charset. This value is statically allocated.
* charset. This value is statically allocated, and should be copied
* in case the locale's charset will be changed later using setlocale()
* or in some other way.
*/
gboolean g_get_charset (char **charset);

View File

@ -29,6 +29,10 @@
#include "glib.h"
#ifdef G_OS_WIN32
#include <windows.h>
#endif
#define UTF8_COMPUTE(Char, Mask, Len) \
if (Char < 128) \
{ \
@ -318,8 +322,21 @@ g_utf8_get_charset_internal (char **a)
}
#endif
#ifdef G_OS_WIN32
if (a && ! *a)
{
static char codepage[10];
sprintf (codepage, "CP%d", GetACP ());
*a = codepage;
/* What about codepage 1200? Is that UTF-8? */
return FALSE;
}
#else
if (a && ! *a)
*a = "US-ASCII";
#endif
/* Assume this for compatibility at present. */
return FALSE;
}

View File

@ -86,7 +86,6 @@ EXPORTS
g_param_value_set_default
g_param_value_validate
g_param_values_cmp
g_signal_add_emission_hook_full
g_signal_connect_closure
g_signal_connect_closure_by_id
g_signal_connect_data
@ -112,7 +111,6 @@ EXPORTS
g_signal_new_valist
g_signal_parse_name
g_signal_query
g_signal_remove_emission_hook
g_signal_stop_emission
g_signal_type_cclosure_new
g_type_add_class_cache_func

View File

@ -105,7 +105,9 @@ typedef enum
/* Returns TRUE if current locale uses UTF-8 charset. If CHARSET is
* not null, sets *CHARSET to the name of the current locale's
* charset. This value is statically allocated.
* charset. This value is statically allocated, and should be copied
* in case the locale's charset will be changed later using setlocale()
* or in some other way.
*/
gboolean g_get_charset (char **charset);

17
gutf8.c
View File

@ -29,6 +29,10 @@
#include "glib.h"
#ifdef G_OS_WIN32
#include <windows.h>
#endif
#define UTF8_COMPUTE(Char, Mask, Len) \
if (Char < 128) \
{ \
@ -318,8 +322,21 @@ g_utf8_get_charset_internal (char **a)
}
#endif
#ifdef G_OS_WIN32
if (a && ! *a)
{
static char codepage[10];
sprintf (codepage, "CP%d", GetACP ());
*a = codepage;
/* What about codepage 1200? Is that UTF-8? */
return FALSE;
}
#else
if (a && ! *a)
*a = "US-ASCII";
#endif
/* Assume this for compatibility at present. */
return FALSE;
}