diff --git a/ChangeLog b/ChangeLog index cbc39225..9164cb74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-05-25 David Lawrence Ramsey + + * configure.ac, nano.c (main): Replace the current hackish check + for a UTF-8 locale with a proper call to nl_langinfo(). + 2007-05-22 David Lawrence Ramsey * browser.c (do_browser), nano.c (do_mouse), prompt.c diff --git a/configure.ac b/configure.ac index f3d104b1..9720485d 100644 --- a/configure.ac +++ b/configure.ac @@ -379,7 +379,7 @@ dnl Checks for functions. AC_CHECK_FUNCS(getdelim getline isblank strcasecmp strcasestr strncasecmp strnlen vsnprintf) if test x$enable_utf8 != xno; then - AC_CHECK_FUNCS(iswalnum iswblank iswpunct iswspace mblen mbstowcs mbtowc wctomb wcwidth) + AC_CHECK_FUNCS(iswalnum iswblank iswpunct iswspace nl_langinfo mblen mbstowcs mbtowc wctomb wcwidth) fi if test x$ac_cv_func_vsnprintf = xno; then @@ -453,12 +453,13 @@ if test x$enable_utf8 != xno && \ test x$ac_cv_func_iswalnum = xyes && \ test x$ac_cv_func_iswpunct = xyes && \ (test x$ac_cv_func_iswblank = xyes || test x$ac_cv_func_iswspace = xyes) && \ + test x$ac_cv_func_nl_langinfo = xyes && \ test x$ac_cv_func_mblen = xyes && \ test x$ac_cv_func_mbstowcs = xyes && \ test x$ac_cv_func_mbtowc = xyes && \ test x$ac_cv_func_wctomb = xyes && \ test x$ac_cv_func_wcwidth = xyes; then - AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).]) + AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), nl_langinfo, mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).]) else if test x$enable_utf8 = xyes; then AC_MSG_ERROR([ diff --git a/src/nano.c b/src/nano.c index fe0dcbfd..6eeeadb7 100644 --- a/src/nano.c +++ b/src/nano.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #ifdef HAVE_GETOPT_H #include @@ -1725,12 +1726,12 @@ int main(int argc, char **argv) #ifdef ENABLE_UTF8 { - /* If the locale set exists and includes the case-insensitive - * string "UTF8" or "UTF-8", we should use UTF-8. */ + /* If the locale set exists and uses UTF-8, we should use + * UTF-8. */ char *locale = setlocale(LC_ALL, ""); - if (locale != NULL && (strcasestr(locale, "UTF8") != NULL || - strcasestr(locale, "UTF-8") != NULL)) { + if (locale != NULL && (strcmp(nl_langinfo(CODESET), + "UTF-8") == 0)) { #ifdef USE_SLANG SLutf8_enable(1); #endif