diff --git a/src/nano.c b/src/nano.c
index 3f26c7b2e22fab3d526327b306a87ae119b419d0..1b927f7e8feb97c9cf05103572f23185d528a4e9 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -3983,8 +3983,14 @@ int main(int argc, char **argv)
 	char *locale = setlocale(LC_ALL, "");
 
 	if (locale == NULL || (locale != NULL &&
+#ifdef HAVE_STRCASESTR
 		strcasestr(locale, "UTF8") == NULL &&
-		strcasestr(locale, "UTF-8") == NULL))
+		strcasestr(locale, "UTF-8") == NULL
+#else
+		nstrcasestr(locale, "UTF8") == NULL &&
+		nstrcasestr(locale, "UTF-8") == NULL
+#endif
+		))
 	    SET(NO_UTF8);
 
 #ifdef USE_SLANG