This function returns true if git is running under an UTF-8 locale. pcre in the next patch will need this. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- gettext.c | 7 ++++++- gettext.h | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gettext.c b/gettext.c index 7378ba2..601bc80 100644 --- a/gettext.c +++ b/gettext.c @@ -166,12 +166,17 @@ void git_setup_gettext(void) textdomain("git"); } +int is_utf8_locale(void) +{ + return !strcmp(charset, "UTF-8"); +} + /* return the number of columns of string 's' in current locale */ int gettext_width(const char *s) { static int is_utf8 = -1; if (is_utf8 == -1) - is_utf8 = !strcmp(charset, "UTF-8"); + is_utf8 = is_utf8_locale(); return is_utf8 ? utf8_strwidth(s) : strlen(s); } diff --git a/gettext.h b/gettext.h index 33696a4..5e733d4 100644 --- a/gettext.h +++ b/gettext.h @@ -31,6 +31,7 @@ #ifndef NO_GETTEXT extern void git_setup_gettext(void); extern int gettext_width(const char *s); +extern int is_utf8_locale(void); #else static inline void git_setup_gettext(void) { @@ -39,6 +40,10 @@ static inline int gettext_width(const char *s) { return strlen(s); } +static inline int is_utf8_locale(void) +{ + return 0; +} #endif #ifdef GETTEXT_POISON -- 2.3.0.rc1.137.g477eb31 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html