Update of /cvsroot/libexif/exif/exif
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6219/exif
Modified Files:
exif-i18n.c exif-i18n.h
Log Message:
Fixed a double character encoding conversion problem with recent
GNU gettext because version >= 0.10.36 does the conversion of message
texts itself. The user must configure with --enable-gettext-iconv when
using a gettext that does NOT do the conversion itself.
Index: exif-i18n.c
===================================================================
RCS file: /cvsroot/libexif/exif/exif/exif-i18n.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -p -d -r1.6 -r1.7
--- exif-i18n.c 25 Nov 2007 09:13:27 -0000 1.6
+++ exif-i18n.c 25 Jan 2008 03:34:03 -0000 1.7
@@ -13,25 +13,29 @@
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
const char *
-exif_i18n_convert_utf8_to_lat1 (const char *in)
+exif_i18n_convert_utf8_to_locale (const char *in)
{
- if (!in)
- return "";
-
-#ifdef HAVE_ICONV
+#if defined(ENABLE_GETTEXT_ICONV) && defined(HAVE_ICONV)
+ /* If gettext() doesn't convert the message texts into the proper
+ * encoding for the current locale, then it's broken (because there's
+ * no way for the app to know the encoding of the translated text).
+ * In this case, assume the translated text is in UTF-8 (which could
+ * be wrong) and use iconv to convert to the proper encoding.
+ */
static iconv_t tr = 0;
size_t t = (in ? strlen (in) : 0);
static char buf[2048];
size_t buf_size = sizeof (buf);
char *out = buf;
- if (!in) return NULL;
+ if (!in) return "";
memset (buf, 0, sizeof (buf));
if (!tr) tr = iconv_open (nl_langinfo (CODESET), "UTF-8");
iconv (tr, (char **) &in, &t, (char **) &out, &buf_size);
return buf;
#else
+ if (!in) return "";
return in;
#endif
}
Index: exif-i18n.h
===================================================================
RCS file: /cvsroot/libexif/exif/exif/exif-i18n.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -p -d -r1.4 -r1.5
--- exif-i18n.h 6 Jan 2008 02:39:54 -0000 1.4
+++ exif-i18n.h 25 Jan 2008 03:34:03 -0000 1.5
@@ -43,8 +43,14 @@
#endif
-const char *exif_i18n_convert_utf8_to_lat1 (const char *);
-#define C(s) (exif_i18n_convert_utf8_to_lat1(s))
+/*! Convert a string from UTF-8 into one appropriate for the current locale
+ * if gettext doesn't doesn't do the conversion itself.
+ * If given a NULL pointer, returns a pointer to an empty string.
+ * \param[in] in the string to convert
+ * \returns pointer to converted string, which may be in a static buffer
+ */
+const char *exif_i18n_convert_utf8_to_locale (const char *);
+#define C(s) (exif_i18n_convert_utf8_to_locale(s))
#endif /* __I18N_H__ */
|