[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/4] quotearg: use Unicode quotes in UTF-8 locales when no transl
From: |
Paolo Bonzini |
Subject: |
[PATCH 3/4] quotearg: use Unicode quotes in UTF-8 locales when no translation is available |
Date: |
Mon, 19 Dec 2011 09:11:22 +0100 |
From: Paolo Bonzini <address@hidden>
* lib/quotearg.c (gettext_quote): Hard-code U+2018 and U+2019 when using
an UTF-8 locale.
* lib/quotearg.h (locale_quoting_style): Do not put an example in text,
since this would be wrong when using Unicode.
* modules/quotearg: Depend on c-strcaseeq.
---
lib/quotearg.c | 18 ++++++++++++++++--
lib/quotearg.h | 6 ++++--
modules/quotearg | 1 +
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/lib/quotearg.c b/lib/quotearg.c
index 84f1f10..a60baba 100644
--- a/lib/quotearg.c
+++ b/lib/quotearg.c
@@ -29,6 +29,7 @@
#include "quotearg.h"
#include "xalloc.h"
+#include "c-strcaseeq.h"
#include <ctype.h>
#include <errno.h>
@@ -188,8 +189,21 @@ static char const *
gettext_quote (char const *msgid, enum quoting_style s)
{
char const *translation = _(msgid);
- if (translation == msgid && s == clocale_quoting_style)
- translation = "\"";
+ char const *locale_code;
+
+ if (translation != msgid)
+ return translation;
+
+ assert (s == clocale_quoting_style || s == locale_quoting_style);
+
+ /* For UTF-8, use single quotes. */
+ locale_code = locale_charset ();
+ if (STRCASEEQ (locale_code, "UTF-8", 'U','T','F','-','8',0,0,0,0))
+ return msgid[0] == '`' ? "\xe2\x80\x98": "\xe2\x80\x99";
+
+ if (s == clocale_quoting_style)
+ return "\"";
+
return translation;
}
diff --git a/lib/quotearg.h b/lib/quotearg.h
index 2756d76..fff085a 100644
--- a/lib/quotearg.h
+++ b/lib/quotearg.h
@@ -112,8 +112,10 @@ enum quoting_style
*/
escape_quoting_style,
- /* Like clocale_quoting_style, but quote `like this' instead of
- "like this" in the default C locale (ls --quoting-style=locale).
+ /* Like clocale_quoting_style, but use single quotes in the
+ default C locale or if the program does not use gettext
+ (ls --quoting-style=locale). For UTF-8 locales, quote
+ characters will use Unicode.
LC_MESSAGES=C
quotearg_buffer:
diff --git a/modules/quotearg b/modules/quotearg
index b3f1ad1..e0b430f 100644
--- a/modules/quotearg
+++ b/modules/quotearg
@@ -9,6 +9,7 @@ m4/mbrtowc.m4
m4/quotearg.m4
Depends-on:
+c-strcaseeq
extensions
gettext-h
mbrtowc
--
1.7.7.1