diff --git a/configure.ac b/configure.ac
index a0c8fdf866343c60b5f1e4ca112e99db9f28ad08..bca57e69347eff56c4590db205af81650086ae2b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -98,7 +98,7 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h langinfo.h limits.h loc
                   sys/param.h sys/socket.h sys/time.h sys/timeb.h \
                   unistd.h wchar.h wctype.h \
                   CoreServices/CoreServices.h \
-                  endian.h machine/endian.h \
+                  endian.h machine/endian.h arpa/nameser_compat.h \
                  ])
 
 # Checks for typedefs, structures, and compiler characteristics.
@@ -157,7 +157,7 @@ AC_COMPILE_IFELSE(  [AC_LANG_PROGRAM([[#include <wchar.h>]],
                  )
 AC_MSG_CHECKING([for wcsrtombs])
 AC_COMPILE_IFELSE(  [AC_LANG_PROGRAM([[#include <wchar.h>]],
-                                     [[mbstate_t st; char buffer[2]; wchar_t src[2]; wcsrtombs(buffer, &src, 2, &st);]])],
+                                     [[mbstate_t st; char buffer[2]; const wchar_t* src=0; wcsrtombs(buffer, &src, 2, &st);]])],
                     [
                       AC_MSG_RESULT([yes])
                       AC_DEFINE_UNQUOTED([HAVE_WCSRTOMBS], 1, [Define to 1 if you have the `wcsrtombs' function.])
@@ -169,7 +169,7 @@ AC_COMPILE_IFELSE(  [AC_LANG_PROGRAM([[#include <wchar.h>]],
                  )
 AC_MSG_CHECKING([for mbsrtowcs])
 AC_COMPILE_IFELSE(  [AC_LANG_PROGRAM([[#include <wchar.h>]],
-                                     [[mbstate_t st; wchar_t buffer[2]; char src[2]; mbsrtowcs(buffer, &src, 2, &st);]])],
+                                     [[mbstate_t st; wchar_t buffer[2]; const char* src=0; mbsrtowcs(buffer, &src, 2, &st);]])],
                     [
                       AC_MSG_RESULT([yes])
                       AC_DEFINE_UNQUOTED([HAVE_MBSRTOWCS], 1, [Define to 1 if you have the `mbsrtowcs' function.])
diff --git a/m4/xerces_transcoder_selection.m4 b/m4/xerces_transcoder_selection.m4
index ebacba38333e3ae81d3cac768c97f06c32ef1f4c..765f2cf4920e49359880bff930d022700272a7f2 100644
--- a/m4/xerces_transcoder_selection.m4
+++ b/m4/xerces_transcoder_selection.m4
@@ -24,8 +24,18 @@ AC_DEFUN([XERCES_TRANSCODER_SELECTION],
 	# Check for GNU iconv support
 	no_GNUiconv=false
 	AC_CHECK_HEADERS([iconv.h wchar.h string.h stdlib.h stdio.h ctype.h locale.h errno.h], [], [no_GNUiconv=true])
-    # The code in iconv loads either endian.h or machine/endian.h, so verify that at least one is present
-	AC_CHECK_HEADER([endian.h], [], [AC_CHECK_HEADER([machine/endian.h],[],[no_GNUiconv=true])])
+        # The code in iconv needs just on of these include files
+	AC_CHECK_HEADER([endian.h], 
+                        [], 
+                        [
+                         AC_CHECK_HEADER([machine/endian.h],
+                                         [],
+                                         [
+                                          AC_CHECK_HEADER([arpa/nameser_compat.h],
+                                                          [],
+                                                          [no_GNUiconv=true])
+                                         ])
+                        ])
 	AC_CHECK_FUNCS([iconv_open iconv_close iconv], [], [no_GNUiconv=true])
 	AC_MSG_CHECKING([whether we can support the GNU iconv Transcoder])
 	list_add=
diff --git a/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp b/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp
index ae868ecbc28ade8d495b228dbc8c2222e3081783..9ab5f0e48386be4362bd0c42d60a1475861a799e 100644
--- a/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp
+++ b/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp
@@ -22,44 +22,23 @@
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
+#if HAVE_CONFIG_H
+  #include <config.h>
+#endif
+
 #include <ctype.h>
 
 #include <locale.h>
 #include <errno.h>
+
 #if HAVE_ENDIAN_H
   #include <endian.h>
 #elif HAVE_MACHINE_ENDIAN_H
   #include <machine/endian.h>
+#elif HAVE_ARPA_NAMESER_COMPAT_H
+  #include <arpa/nameser_compat.h>
 #endif
 
-#include <xercesc/util/XMLString.hpp>
-#include <xercesc/util/XMLUniDefs.hpp>
-#include <xercesc/util/XMLUni.hpp>
-#include <xercesc/util/PlatformUtils.hpp>
-#include <xercesc/util/TranscodingException.hpp>
-#include <xercesc/util/Janitor.hpp>
-#include "IconvGNUTransService.hpp"
-
-XERCES_CPP_NAMESPACE_BEGIN
-
-// ---------------------------------------------------------------------------
-// Description of encoding schemas, supported by iconv()
-// ---------------------------------------------------------------------------
-typedef struct __IconvGNUEncoding {
-    const char*    fSchema;    // schema name
-    size_t    fUChSize;    // size of the character
-    unsigned int fUBO;        // byte order, relative to the host
-} IconvGNUEncoding;
-
-static const IconvGNUEncoding    gIconvGNUEncodings[] = {
-    { "UTF-16LE",        2,    LITTLE_ENDIAN },
-    { "UTF-16BE",        2,    BIG_ENDIAN },
-    { "UCS-2LE",         2,    LITTLE_ENDIAN },
-    { "UCS-2BE",         2,    BIG_ENDIAN },
-    { "UCS-2-INTERNAL",  2,    BYTE_ORDER },
-    { NULL,              0,    0 }
-};
-
 #define MAX_UCHSIZE 4
 
 //--------------------------------------------------
@@ -124,12 +103,39 @@ static const IconvGNUEncoding    gIconvGNUEncodings[] = {
 # endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 #include <wchar.h>
-
-
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
 
+#include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/XMLUniDefs.hpp>
+#include <xercesc/util/XMLUni.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+#include <xercesc/util/TranscodingException.hpp>
+#include <xercesc/util/Janitor.hpp>
+#include "IconvGNUTransService.hpp"
+
+
+XERCES_CPP_NAMESPACE_BEGIN
+
+// ---------------------------------------------------------------------------
+// Description of encoding schemas, supported by iconv()
+// ---------------------------------------------------------------------------
+typedef struct __IconvGNUEncoding {
+    const char*    fSchema;    // schema name
+    size_t    fUChSize;    // size of the character
+    unsigned int fUBO;        // byte order, relative to the host
+} IconvGNUEncoding;
+
+static const IconvGNUEncoding    gIconvGNUEncodings[] = {
+    { "UTF-16LE",        2,    LITTLE_ENDIAN },
+    { "UTF-16BE",        2,    BIG_ENDIAN },
+    { "UCS-2LE",         2,    LITTLE_ENDIAN },
+    { "UCS-2BE",         2,    BIG_ENDIAN },
+    { "UCS-2-INTERNAL",  2,    BYTE_ORDER },
+    { NULL,              0,    0 }
+};
+
 // ---------------------------------------------------------------------------
 //  Local, const data
 // ---------------------------------------------------------------------------
@@ -236,7 +242,7 @@ XMLCh IconvGNUWrapper::toUpper (const XMLCh ch)
     xmlChToMbc (ch, wcbuf);
 
     char    tmpArr[4];
-    char*    ptr = wcbuf;
+    const char* ptr = wcbuf;
     size_t    len = fUChSize;
     char    *pTmpArr = tmpArr;
     size_t    bLen = 2;
@@ -265,7 +271,7 @@ XMLCh IconvGNUWrapper::toLower (const XMLCh ch)
     xmlChToMbc (ch, wcbuf);
 
     char    tmpArr[4];
-    char*    ptr = wcbuf;
+    const char* ptr = wcbuf;
     size_t    len = fUChSize;
     char    *pTmpArr = tmpArr;
     size_t    bLen = 2;
@@ -366,7 +372,7 @@ size_t    IconvGNUWrapper::iconvFrom ( const char    *fromPtr,
                  char        **toPtr,
                  size_t        toLen )
 {
-    char ** tmpPtr = (char**)&fromPtr;
+    const char ** tmpPtr = &fromPtr;
     return ::iconv (fCDFrom, tmpPtr, fromLen, toPtr, &toLen);
 }
 
@@ -375,7 +381,7 @@ size_t    IconvGNUWrapper::iconvTo ( const char    *fromPtr,
                    char        **toPtr,
                    size_t        toLen )
 {
-    char ** tmpPtr = (char**)&fromPtr;
+    const char ** tmpPtr = &fromPtr;
     return ::iconv (fCDTo, tmpPtr, fromLen, toPtr, &toLen);
 }
 
@@ -409,7 +415,7 @@ IconvGNUTransService::IconvGNUTransService(MemoryManager* manager)
         strcmp (fLocalCP, "POSIX") == 0)
         fLocalCP = "iso-8859-1";    // fallback locale
     else {
-        char    *ptr = strchr (fLocalCP, '.');
+        const char *ptr = strchr (fLocalCP, '.');
         if (ptr == NULL)
             fLocalCP = "iso-8859-1";    // fallback locale
         else