+ NCURSES_CH_T attr = CHDEREF(ch);
+
+ TR(TRACE_CHARPUT, ("PutAttrChar(%s) at (%d, %d)",
+ _tracech_t(ch),
+ SP->_cursrow, SP->_curscol));
+#if USE_WIDEC_SUPPORT
+ /*
+ * If this is not a valid character, there is nothing more to do.
+ */
+ if (isWidecExt(CHDEREF(ch))) {
+ TR(TRACE_CHARPUT, ("...skip"));
+ return;
+ }
+ /*
+ * Determine the number of character cells which the 'ch' value will use
+ * on the screen. It should be at least one.
+ */
+ if ((chlen = wcwidth(CharOf(CHDEREF(ch)))) <= 0) {
+ static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
+
+ /*
+ * If the character falls into any of these special cases, do
+ * not force the result to a blank:
+ *
+ * a) it is printable (this works around a bug in wcwidth()).
+ * b) use_legacy_coding() has been called to modify the treatment
+ * of codes 128-255.
+ * c) the acs_map[] has been initialized to allow codes 0-31
+ * to be rendered. This supports Linux console's "PC"
+ * characters. Codes 128-255 are allowed though this is
+ * not checked.
+ */
+ if (is8bits(CharOf(CHDEREF(ch)))
+ && (isprint(CharOf(CHDEREF(ch)))
+ || (SP->_legacy_coding > 0 && CharOf(CHDEREF(ch)) >= 160)
+ || (SP->_legacy_coding > 1 && CharOf(CHDEREF(ch)) >= 128)
+ || (AttrOf(attr) & A_ALTCHARSET
+ && ((CharOfD(ch) < ACS_LEN
+ && SP->_acs_map != 0
+ && SP->_acs_map[CharOfD(ch)] != 0)
+ || (CharOfD(ch) >= 128))))) {
+ ;
+ } else {
+ ch = CHREF(blank);
+ TR(TRACE_CHARPUT, ("forced to blank"));
+ }
+ chlen = 1;
+ }
+#endif