aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-06-01 01:57:33 -0300
committerdequis <dx@dxzone.com.ar>2015-06-04 14:13:22 -0300
commit3a27896e4c1106ed6f48bce3d41ac4c4aa330a46 (patch)
tree354de075bf66af698bba2cec32f8e7110435e36e
parent1cef55f237128691fb56bbdb3f599df463ecbad3 (diff)
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)
-rw-r--r--nick.c12
1 files changed, 10 insertions, 2 deletions
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))) {