From 3a27896e4c1106ed6f48bce3d41ac4c4aa330a46 Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 1 Jun 2015 01:57:33 -0300 Subject: nick_gen: retry g_convert_with_fallback without //TRANSLIT if it fails Based on patch from trac ticket #1152. Quoting: >NetBSD's implementation of iconv does not appear to support //TRANSLIT. >This means g_convert_with_fallback() called with //TRANSLIT will always fail Removed the log_message part of the patch since that's daemon level logging and it's unlikely to fail twice anyway (even if it did, it wouldn't crash) --- nick.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'nick.c') diff --git a/nick.c b/nick.c index 31cf4f34..9c47c2fe 100644 --- a/nick.c +++ b/nick.c @@ -185,8 +185,16 @@ char *nick_gen(bee_user_t *bu) accents don't just get stripped. Note that it depends on LC_CTYPE being set to something other than C/POSIX. */ if (!(irc && irc->status & IRC_UTF8_NICKS)) { - part = asc = g_convert_with_fallback(part, -1, "ASCII//TRANSLIT", - "UTF-8", "", NULL, NULL, NULL); + asc = g_convert_with_fallback(part, -1, "ASCII//TRANSLIT", "UTF-8", "", NULL, NULL, NULL); + + if (!asc) { + /* If above failed, try again without //TRANSLIT. + //TRANSLIT is a GNU iconv special and is not POSIX. + Other platforms may not support it. */ + asc = g_convert_with_fallback(part, -1, "ASCII", "UTF-8", "", NULL, NULL, NULL); + } + + part = asc; } if (part && chop && (s = strchr(part, chop))) { -- cgit v1.2.3