From 102a68f01edf9146e3841c40ab2400e8e28fccd8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 9 Feb 2006 22:43:31 +0000 Subject: [PATCH] eliminating iconv in favor of the encoding in libxml2 --- src/common/gamecode/xmlreport.c | 21 +++++++-------------- src/common/kernel/xmlreader.c | 27 +++++---------------------- src/eressea/Jamfile | 2 -- src/eressea/eressea-lua.vcproj | 10 +++++----- src/eressea/eressea.vcproj | 8 ++++---- src/mapper/Jamfile | 1 - src/mapper/mapper.vcproj | 10 +++++----- 7 files changed, 26 insertions(+), 53 deletions(-) diff --git a/src/common/gamecode/xmlreport.c b/src/common/gamecode/xmlreport.c index ec06b0e5d..edaaf6abb 100644 --- a/src/common/gamecode/xmlreport.c +++ b/src/common/gamecode/xmlreport.c @@ -81,24 +81,17 @@ #define L10N(x) x -#ifdef USE_ICONV -static iconv_t utf8; -#endif - static xmlChar* xml_s(const char * str) { - static char buffer[1024]; + static xmlChar buffer[1024]; const char * inbuf = str; - char * outbuf = buffer; - size_t inbytes = strlen(str)+1; - size_t outbytes = sizeof(buffer); -#ifdef USE_ICONV - iconv(utf8, (char**)&inbuf, &inbytes, (char**)&outbuf, &outbytes); -#else - isolat1ToUTF8(outbuf, &outbytes, inbuf, &inbytes); -#endif - return (xmlChar*)buffer; + xmlChar * outbuf = buffer; + int inbytes = (int)strlen(str)+1; + int outbytes = (int)sizeof(buffer); + + isolat1ToUTF8(outbuf, &outbytes, BAD_CAST inbuf, &inbytes); + return buffer; } static xmlChar* diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index 8e010f0c2..1ff240893 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -38,9 +38,6 @@ without prior permission by the authors of Eressea. #include #include #include -#ifdef USE_ICONV -#include -#endif /* libc includes */ #include @@ -85,27 +82,13 @@ static const char * xml_to_locale(const xmlChar * xmlStr) { static char zText[1024]; - char * inbuf = (char*)xmlStr; + const xmlChar * inbuf = xmlStr; char * outbuf = zText; - size_t inbytes = strlen((const char*)xmlStr)+1; - size_t outbytes = sizeof(zText); -#ifdef USE_ICONV - static iconv_t context = (iconv_t)-1; + int inbytes = (int)strlen((const char*)xmlStr)+1; + int outbytes = (int)sizeof(zText); - if (context==(iconv_t)-1) { - context = iconv_open("", "UTF-8"); - } - assert(context!=(iconv_t)-1); - - iconv(context, &inbuf, &inbytes, &outbuf, &outbytes); -#else - size_t insize = inbytes; - if (UTF8Toisolat1(outbuf, &outbytes, inbuf, &inbytes)>=0) { - inbytes -= insize; - } -#endif - if (inbytes!=0) { - log_error(("string is too long: %d chars remain in %s.\n", inbytes, (const char*)xmlStr)); + if (UTF8Toisolat1((xmlChar*)outbuf, &outbytes, inbuf, &inbytes)<0) { + log_error(("string is too long: %s.\n", (const char*)xmlStr)); } return zText; } diff --git a/src/eressea/Jamfile b/src/eressea/Jamfile index 3fe595a06..7c78175f0 100644 --- a/src/eressea/Jamfile +++ b/src/eressea/Jamfile @@ -37,12 +37,10 @@ LinkLibraries $(SERVER) : LinkLibraries $(LUASERVER) : gamecode kernel items modules attributes spells races triggers util ; -iconv $(SERVER) ; libxml2 $(SERVER) ; LINKLIBS on $(SERVER) += -L$(LUABIND_ROOT)/lib -lm ; luabind $(LUASERVER) ; -iconv $(LUASERVER) ; libxml2 $(LUASERVER) ; LINKLIBS on $(LUASERVER) += -lm -ldl -lstdc++ ; diff --git a/src/eressea/eressea-lua.vcproj b/src/eressea/eressea-lua.vcproj index 029661a61..674170901 100644 --- a/src/eressea/eressea-lua.vcproj +++ b/src/eressea/eressea-lua.vcproj @@ -44,7 +44,7 @@