+ int result = 0;
+#if defined(__MINGW32__) && USE_WIDEC_SUPPORT
+ result = 1;
+#elif HAVE_LANGINFO_CODESET
+ char *env = nl_langinfo(CODESET);
+ result = !strcmp(env, "UTF-8");
+ T(("_nc_unicode_locale(%s) ->%d", env, result));
+#else
+ char *env = _nc_get_locale();
+ if (env != 0) {
+ if (strstr(env, ".UTF-8") != 0) {
+ result = 1;
+ T(("_nc_unicode_locale(%s) ->%d", env, result));
+ }
+ }
+#endif
+ return result;
+}
+
+#define CONTROL_N(s) ((s) != 0 && strstr(s, "\016") != 0)
+#define CONTROL_O(s) ((s) != 0 && strstr(s, "\017") != 0)
+
+/*
+ * Check for known broken cases where a UTF-8 locale breaks the alternate
+ * character set.
+ */
+NCURSES_EXPORT(int)
+_nc_locale_breaks_acs(TERMINAL * termp)
+{
+ const char *env_name = "NCURSES_NO_UTF8_ACS";
+ const char *env;
+ int value;
+ int result = 0;
+
+ T((T_CALLED("_nc_locale_breaks_acs:%d"), result));
+ if (getenv(env_name) != 0) {
+ result = _nc_getenv_num(env_name);
+ } else if ((value = tigetnum("U8")) >= 0) {
+ result = value; /* use extension feature */
+ } else if ((env = getenv("TERM")) != 0) {
+ if (strstr(env, "linux")) {
+ result = 1; /* always broken */
+ } else if (strstr(env, "screen") != 0
+ && ((env = getenv("TERMCAP")) != 0
+ && strstr(env, "screen") != 0)
+ && strstr(env, "hhII00") != 0) {
+ if (CONTROL_N(enter_alt_charset_mode) ||
+ CONTROL_O(enter_alt_charset_mode) ||
+ CONTROL_N(set_attributes) ||
+ CONTROL_O(set_attributes)) {
+ result = 1;
+ }
+ }
+ }
+ returnCode(result);
+}
+
+NCURSES_EXPORT(int)
+TINFO_SETUP_TERM(TERMINAL ** tp,
+ NCURSES_CONST char *tname,
+ int Filedes,
+ int *errret,
+ int reuse)
+{
+#ifdef USE_TERM_DRIVER
+ TERMINAL_CONTROL_BLOCK *TCB = 0;
+#else