[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RFC: Solving gettext & UTF-8 brokenness

From: Erik Huelsmann <e.huelsmann_at_gmx.net>
Date: 2004-05-01 12:25:31 CEST

Currently trunk is very broken wrt the return value of *gettext() calls and
the assumption that Subversion uses UTF-8 internally.

Instead of disabling NLS entirely until the matter has been settled (which
was my first reaction), I propose a path to a solution in two steps:

1) Committing the patch below which disables NLS only if it can't be
instructed to return UTF-8 encoded strings (bind_textdomain_codeset not

This condition means that all non-gnu gettext implementations are affected,
with the exception of Solaris gettext in Solaris 8 (starting at a certain
patch level) and Solaris 9.

2) Write proxy functions for the *gettext() calls in a newly created
svn_gtxt_* namespace which convert return values from the current locale to
UTF-8 (probably added to libsvn_subr); the gettext calls can be routed to
these functions if the conditions of (1) are not met.

When _() and *gettext() return utf-8 all data passed to 'the outside world'
(printf and others) will have to be translated to the active charset;
svn_cmdline_cstring_from_utf8_fuzzy should do that.

This patch has been verified to work on my system; which is hardly
surprising since it is an english gnu linux system with UTF-8 locale...

Fix UTF-8 & gettext brokenness

* configure.in (ENABLE_NLS): disable NLS (for now) if there is no
   way to assure UTF-8 output

* svn_private_config.hw: define HAVE_BIND_TEXTDOMAIN_CODESET assuming
   to be building against GNU gettext

* subversion/libsvn_subr/cmdline.c (svn_cmdline_init): tell gettext to
   return UTF-8 data for the Subversion domain


Index: configure.in
--- configure.in (revision 9587)
+++ configure.in (working copy)
@@ -282,6 +282,18 @@
                     AC_MSG_WARN([bindtextdomain() not found. Disabling
+ AC_SEARCH_LIBS(bind_textdomain_codeset, [intl],
+ [
+ [Define to 1 if bind_textdomain_codeset
+ is available for setting gettext output
+ encoding])
+ ],
+ [
+ AC_MSG_WARN([bind_textdomain_codeset() not found.
+ Disabling NLS.])
+ enable_nls="no"
+ ])
     if test "$enable_nls" = "yes"; then
                 [Define to 1 if translation of program messages to the
Index: subversion/libsvn_subr/cmdline.c
--- subversion/libsvn_subr/cmdline.c (revision 9587)
+++ subversion/libsvn_subr/cmdline.c (working copy)
@@ -164,11 +164,16 @@
     apr_pool_destroy (pool);
- bindtextdomain(PACKAGE_NAME, SVN_LOCALE_DIR);
+ bindtextdomain (PACKAGE_NAME, SVN_LOCALE_DIR);
+#endif /* WIN32 */
+ bind_textdomain_codeset (PACKAGE_NAME, "UTF-8");
- textdomain(PACKAGE_NAME);
+ textdomain (PACKAGE_NAME);
+#endif /* ENABLE_NLS */
   return EXIT_SUCCESS;
Index: svn_private_config.hw
--- svn_private_config.hw (revision 9587)
+++ svn_private_config.hw (working copy)
@@ -59,6 +59,10 @@
 #define PACKAGE_NAME "subversion"
 #ifdef ENABLE_NLS
+/* assume building against gnu gettext variant */
 #define SVN_LOCALE_RELATIVE_PATH "../share/locale"
 #include <locale.h>
 #include <libintl.h>

"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
Jetzt aktivieren unter http://www.gmx.net/info
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat May 1 12:25:57 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.