$NetBSD: patch-aa,v 1.7 2007/04/25 13:36:18 sborrill Exp $

--- camlibs/ptp2/library.c.orig	2007-01-30 20:06:58.000000000 -0500
+++ camlibs/ptp2/library.c	2007-01-30 20:13:25.000000000 -0500
@@ -50,23 +50,6 @@
 #  define N_(String) (String)
 #endif
 
-/*
- * On MacOS (Darwin) and *BSD we're not using glibc, but libiconv.
- * glibc knows that UCS-2 is to be in the local machine endianness,
- * whereas libiconv does not. So we construct this macro to get
- * things right. Reportedly, glibc 2.1.3 has a bug so that UCS-2
- * is always bigendian though, we would need to work around that
- * too...
- */
-#ifndef __GLIBC__
-#define UCS_2_INTERNAL "UCS-2-INTERNAL"
-#else
-#if (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1 )
-#error "Too old glibc. This versions iconv() implementation cannot be trusted."
-#endif
-#define UCS_2_INTERNAL "UCS-2"
-#endif
-
 #include "ptp.h"
 #include "ptp-bugs.h"
 #include "ptp-private.h"
@@ -3619,7 +3602,7 @@
     	CameraAbilities a;
 	int ret, i, retried = 0;
 	PTPParams *params;
-	char *curloc;
+	char *camloc, *curloc;
 
 	/* Make sure our port is either USB or PTP/IP. */
 	if ((camera->port->type != GP_PORT_USB) && (camera->port->type != GP_PORT_PTPIP)) {
@@ -3649,6 +3632,11 @@
 	memset (camera->pl->params.data, 0, sizeof (PTPData));
 	((PTPData *) camera->pl->params.data)->camera = camera;
 	camera->pl->params.byteorder = PTP_DL_LE;
+    if (camera->pl->params.byteorder == PTP_DL_LE) {
+        camloc = "UCS-2LE";
+    } else {
+        camloc = "UCS-2BE";
+    }
 
 	switch (camera->port->type) {
 	case GP_PORT_USB:
@@ -3696,8 +3684,8 @@
 
 	curloc = nl_langinfo (CODESET);
 	if (!curloc) curloc="UTF-8";
-	camera->pl->params.cd_ucs2_to_locale = iconv_open(curloc, UCS_2_INTERNAL);
-	camera->pl->params.cd_locale_to_ucs2 = iconv_open(UCS_2_INTERNAL, curloc);
+	camera->pl->params.cd_ucs2_to_locale = iconv_open(curloc, camloc);
+	camera->pl->params.cd_locale_to_ucs2 = iconv_open(camloc, curloc);
 	if ((camera->pl->params.cd_ucs2_to_locale == (iconv_t) -1) ||
 	    (camera->pl->params.cd_locale_to_ucs2 == (iconv_t) -1)) {
 		gp_log (GP_LOG_ERROR, "iconv", "Failed to create iconv converter.\n");
