[Freeciv-Dev] Re: (PR#2559) SDL_ttf font problem
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
This should do the trick...
diff -urN -Xfreeciv/diff_ignore freeciv/Makefile.am freeciv-sdl/Makefile.am
--- freeciv/Makefile.am Fri Jan 24 14:50:15 2003
+++ freeciv-sdl/Makefile.am Sat Feb 1 23:13:36 2003
@@ -65,7 +65,7 @@
debian/rules \
debian/watch \
m4/ac_path_lib.m4 \
- m4/codeset.m4 \
+ m4/locale.m4 \
m4/debug.m4 \
m4/esd.m4 \
m4/gettext.m4 \
diff -urN -Xfreeciv/diff_ignore freeciv/m4/codeset.m4 freeciv-sdl/m4/codeset.m4
--- freeciv/m4/codeset.m4 Tue Nov 12 15:06:58 2002
+++ freeciv-sdl/m4/codeset.m4 Thu Jan 1 01:00:00 1970
@@ -1,16 +0,0 @@
-#serial AM1
-dnl From Bruno Haible.
-
-AC_DEFUN([AM_LANGINFO_CODESET],
-[
- AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
- [AC_TRY_LINK([#include <langinfo.h>],
- [char* cs = nl_langinfo(CODESET);],
- am_cv_langinfo_codeset=yes,
- am_cv_langinfo_codeset=no)
- ])
- if test $am_cv_langinfo_codeset = yes; then
- AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
- [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
- fi
-])
diff -urN -Xfreeciv/diff_ignore freeciv/m4/locale.m4 freeciv-sdl/m4/locale.m4
--- freeciv/m4/locale.m4 Thu Jan 1 01:00:00 1970
+++ freeciv-sdl/m4/locale.m4 Sun Feb 2 00:17:40 2003
@@ -0,0 +1,33 @@
+#serial AM1
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_LANGINFO_CODESET],
+[
+ AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
+ [AC_TRY_LINK([#include <langinfo.h>],
+ [char* cs = nl_langinfo(CODESET);],
+ am_cv_langinfo_codeset=yes,
+ am_cv_langinfo_codeset=no)
+ ])
+ if test $am_cv_langinfo_codeset = yes; then
+ AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
+ [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+ fi
+])
+
+AC_DEFUN([AM_LIBCHARSET],
+[
+ AC_CACHE_CHECK([for libcharset], am_cv_libcharset,
+ [lc_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBICONV"
+ AC_TRY_LINK([#include <libcharset.h>],
+ [locale_charset()],
+ am_cv_libcharset=yes,
+ am_cv_libcharset=no)
+ LIBS="$lc_save_LIBS"
+ ])
+ if test $am_cv_libcharset = yes; then
+ AC_DEFINE(HAVE_LIBCHARSET, 1,
+ [Define if you have <libcharset.h> and locale_charset().])
+ fi
+])
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-sdl/gui_iconv.c
freeciv-sdl/client/gui-sdl/gui_iconv.c
--- freeciv/client/gui-sdl/gui_iconv.c Sun Jan 26 15:00:08 2003
+++ freeciv-sdl/client/gui-sdl/gui_iconv.c Sun Feb 2 00:42:15 2003
@@ -30,9 +30,17 @@
#include <stdlib.h>
#include <string.h>
+#include <SDL/SDL_byteorder.h>
#include <SDL/SDL_types.h>
#include <iconv.h>
#include <errno.h>
+#ifdef HAVE_LIBCHARSET
+#include <libcharset.h>
+#else
+#ifdef HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+#endif
#include "gui_mem.h"
#include "unistring.h"
@@ -44,14 +52,25 @@
Uint16 *convert_to_utf16(const char *pString)
{
/* Start Parametrs */
- const char *pTocode = "UTF-16";
- const char *pFromcode = LOCAL_CODE;
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+ const char *pTocode = "UTF-16LE";
+#else
+ const char *pTocode = "UTF-16BE";
+#endif
+#ifdef HAVE_LIBCHARSET
+ const char *pFromcode = locale_charset();
+#else
+#ifdef HAVE_LANGINFO_CODESET
+ const char *pFromcode = nl_langinfo(CODESET);
+#else
+ const char *pFromcode = "";
+#endif
+#endif
const char *pStart = pString;
const char *pEnd = pString + strlen(pString);
/* ===== */
char *pResult = NULL;
- int iIter;
/* From 8 bit code to UTF-16 (16 bit code)
size_t length = 2*(strlen(pString)+1); */
@@ -72,7 +91,7 @@
/* Do the conversion for real. */
{
const char *pInptr = pStart;
- size_t Insize = pEnd - pStart;
+ size_t Insize = pEnd - pStart + 1;
char *pOutptr = pResult;
size_t Outsize = length;
@@ -109,13 +128,6 @@
}
}
- /* Bug Corection */
- for (iIter = 0; iIter < length - 2; iIter++) {
- pResult[iIter] = pResult[iIter + 2];
- }
- pResult[length - 2] = 0;
- pResult[length - 1] = 0;
-
iconv_close(cd);
return (Uint16 *) pResult;
@@ -127,14 +139,25 @@
Uint16 *convertcopy_to_utf16(Uint16 * pToString, const char *pFromString)
{
/* Start Parametrs */
- const char *pTocode = "UTF-16";
- const char *pFromcode = LOCAL_CODE;
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+ const char *pTocode = "UTF-16LE";
+#else
+ const char *pTocode = "UTF-16BE";
+#endif
+#ifdef HAVE_LIBCHARSET
+ const char *pFromcode = locale_charset();
+#else
+#ifdef HAVE_LANGINFO_CODESET
+ const char *pFromcode = nl_langinfo(CODESET);
+#else
+ const char *pFromcode = "";
+#endif
+#endif
const char *pStart = pFromString;
const char *pEnd = pFromString + strlen(pFromString);
/* ===== */
char *pResult = (char *) pToString;
- int iIter;
/* From 8 bit code to UTF-16 (16 bit code)
size_t length = 2*(strlen(pString)+1); */
@@ -157,7 +180,7 @@
/* Do the conversion for real. */
{
const char *pInptr = pStart;
- size_t Insize = pEnd - pStart;
+ size_t Insize = pEnd - pStart + 1;
char *pOutptr = pResult;
size_t Outsize = length;
@@ -192,13 +215,6 @@
}
}
- /* Bug Corection */
- for (iIter = 0; iIter < length - 2; iIter++) {
- pResult[iIter] = pResult[iIter + 2];
- }
- pResult[length - 2] = 0;
- pResult[length - 1] = 0;
-
iconv_close(cd);
return (Uint16 *) pResult;
@@ -210,8 +226,20 @@
char *convert_to_chars(const Uint16 * pUniString)
{
/* Start Parametrs */
- const char *pTocode = LOCAL_CODE;
- const char *pFromcode = "UTF-16";
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+ const char *pFromcode = "UTF-16LE";
+#else
+ const char *pFromcode = "UTF-16BE";
+#endif
+#ifdef HAVE_LIBCHARSET
+ const char *pTocode = locale_charset();
+#else
+#ifdef HAVE_LANGINFO_CODESET
+ const char *pTocode = nl_langinfo(CODESET);
+#else
+ const char *pTocode = "";
+#endif
+#endif
const char *pStart = (char *) pUniString;
const char *pEnd =
(char *) pUniString + (unistrlen(pUniString) << 1) + 2;
diff -urN -Xfreeciv/diff_ignore freeciv/client/gui-sdl/gui_iconv.h
freeciv-sdl/client/gui-sdl/gui_iconv.h
--- freeciv/client/gui-sdl/gui_iconv.h Mon Dec 2 09:47:02 2002
+++ freeciv-sdl/client/gui-sdl/gui_iconv.h Sat Feb 1 19:06:02 2003
@@ -26,8 +26,6 @@
#ifndef FC__GUI_ICONV_H
#define FC__GUI_ICONV_H
-#define LOCAL_CODE "ISO-8859-2"
-
Uint16 *convert_to_utf16(const char *pString);
Uint16 *convertcopy_to_utf16(Uint16 *pToString, const char *pFromString);
char *convert_to_chars(const Uint16 *pUniString);
diff -urN -Xfreeciv/diff_ignore freeciv/m4/sdl-client.m4
freeciv-sdl/m4/sdl-client.m4
--- freeciv/m4/sdl-client.m4 Sat Dec 14 17:36:40 2002
+++ freeciv-sdl/m4/sdl-client.m4 Sat Feb 1 23:24:12 2003
@@ -53,6 +53,8 @@
dnl Check for libiconv (which is usually included in glibc, but may
dnl be distributed separately).
AM_ICONV
+ AM_LIBCHARSET
+ AM_LANGINFO_CODESET
dnl Check for some other libraries - needed under BeOS for instance.
dnl These should perhaps be checked for in all cases?
|
|