Implement #491549: On Windows, always use the native API for character set

2007-11-26  Tor Lillqvist  <tml@novell.com>

	Implement #491549: On Windows, always use the native API for
	character set conversions instead of GNU libiconv. Almost all
	codesets supported by GNU libiconv exist as Windows codepages.
	One missing feature is the "C99" and "JAVA" pseudo codesets, but I
	doubt that is worth worrying about.
	
	* glib/win_iconv.c: New file. iconv() implementation for
	Windows. Placed in the public domain by Yukihiro Nakadaira
	<yukihiro.nakadaira@gmail.com>. From
	http://yukihiro.nakadaira.googlepages.com/win_iconv.zip, his
	2007-11-17 version.

	* glib/gconvert.c: Include win_iconv.c on Windows.

	* configure.in: Bypass iconv checks on Windows. 


svn path=/trunk/; revision=5937
This commit is contained in:
Tor Lillqvist 2007-11-25 23:27:45 +00:00 committed by Tor Lillqvist
parent 6fdcc7ddb2
commit 04aec5b28d
4 changed files with 1900 additions and 34 deletions

View File

@ -1,3 +1,21 @@
2007-11-26 Tor Lillqvist <tml@novell.com>
Implement #491549: On Windows, always use the native API for
character set conversions instead of GNU libiconv. Almost all
codesets supported by GNU libiconv exist as Windows codepages.
One missing feature is the "C99" and "JAVA" pseudo codesets, but I
doubt that is worth worrying about.
* glib/win_iconv.c: New file. iconv() implementation for
Windows. Placed in the public domain by Yukihiro Nakadaira
<yukihiro.nakadaira@gmail.com>. From
http://yukihiro.nakadaira.googlepages.com/win_iconv.zip, his
2007-11-17 version.
* glib/gconvert.c: Include win_iconv.c on Windows.
* configure.in: Bypass iconv checks on Windows.
2007-11-25 Tor Lillqvist <tml@novell.com> 2007-11-25 Tor Lillqvist <tml@novell.com>
* glib/gtestutils.c: Add conditionals for non-Unix. Just g_error() * glib/gtestutils.c: Add conditionals for non-Unix. Just g_error()

View File

@ -376,38 +376,44 @@ dnl ***********************
dnl dnl
dnl We do this before the gettext checks, to avoid distortion dnl We do this before the gettext checks, to avoid distortion
AC_ARG_WITH(libiconv, dnl On Windows we use a native implementation
[AC_HELP_STRING([--with-libiconv=@<:@no/gnu/native@:>@],
[use the libiconv library])],,
[with_libiconv=maybe])
found_iconv=no if test x"$glib_native_win32" = xyes; then
case $with_libiconv in with_libiconv=native
maybe) else
# Check in the C library first AC_ARG_WITH(libiconv,
AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes]) [AC_HELP_STRING([--with-libiconv=@<:@no/gnu/native@:>@],
# Check if we have GNU libiconv [use the libiconv library])],,
if test $found_iconv = "no"; then [with_libiconv=maybe])
found_iconv=no
case $with_libiconv in
maybe)
# Check in the C library first
AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
# Check if we have GNU libiconv
if test $found_iconv = "no"; then
AC_CHECK_LIB(iconv, libiconv_open, [with_libiconv=gnu; found_iconv=yes])
fi
# Check if we have a iconv in -liconv, possibly from vendor
if test $found_iconv = "no"; then
AC_CHECK_LIB(iconv, iconv_open, [with_libiconv=native; found_iconv=yes])
fi
;;
no)
AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
;;
gnu|yes)
AC_CHECK_LIB(iconv, libiconv_open, [with_libiconv=gnu; found_iconv=yes]) AC_CHECK_LIB(iconv, libiconv_open, [with_libiconv=gnu; found_iconv=yes])
fi ;;
# Check if we have a iconv in -liconv, possibly from vendor native)
if test $found_iconv = "no"; then
AC_CHECK_LIB(iconv, iconv_open, [with_libiconv=native; found_iconv=yes]) AC_CHECK_LIB(iconv, iconv_open, [with_libiconv=native; found_iconv=yes])
fi ;;
;; esac
no)
AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
;;
gnu|yes)
AC_CHECK_LIB(iconv, libiconv_open, [with_libiconv=gnu; found_iconv=yes])
;;
native)
AC_CHECK_LIB(iconv, iconv_open, [with_libiconv=native; found_iconv=yes])
;;
esac
if test "x$found_iconv" = "xno" ; then if test "x$found_iconv" = "xno" ; then
AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv]) AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
fi
fi fi
jm_GLIBC21 jm_GLIBC21
@ -465,11 +471,13 @@ dnl
dnl Now we are done with gettext checks, figure out ICONV_LIBS dnl Now we are done with gettext checks, figure out ICONV_LIBS
dnl dnl
if test x$with_libiconv != xno ; then if test x"$glib_native_win32" != xyes; then
case " $INTLLIBS " in if test x$with_libiconv != xno ; then
*[[\ \ ]]-liconv[[\ \ ]]*) ;; case " $INTLLIBS " in
*) ICONV_LIBS="-liconv" ;; *[[\ \ ]]-liconv[[\ \ ]]*) ;;
esac *) ICONV_LIBS="-liconv" ;;
esac
fi
fi fi
AC_SUBST(ICONV_LIBS) AC_SUBST(ICONV_LIBS)

View File

@ -22,13 +22,16 @@
#include "config.h" #include "config.h"
#include "glib.h"
#ifndef G_OS_WIN32
#include <iconv.h> #include <iconv.h>
#endif
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "glib.h"
#include "gprintfint.h" #include "gprintfint.h"
#include "gthreadprivate.h" #include "gthreadprivate.h"
#include "gunicode.h" #include "gunicode.h"
@ -50,6 +53,10 @@
#include "galias.h" #include "galias.h"
#ifdef G_OS_WIN32
#include "win_iconv.c"
#endif
GQuark GQuark
g_convert_error_quark (void) g_convert_error_quark (void)
{ {

1833
glib/win_iconv.c Normal file

File diff suppressed because it is too large Load Diff