+#if USE_WIDEC_SUPPORT
+/*
+ * TODO: support surrogate pairs
+ * TODO: support combining characters
+ * TODO: support acsc
+ * TODO: check wcwidth of base character, fill if needed for double-width
+ * TODO: _nc_wacs should be part of sp.
+ */
+static BOOL
+con_write16(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, cchar_t *str, int n)
+{
+ CHAR_INFO ci[n];
+ COORD loc, siz;
+ SMALL_RECT rec;
+ int i;
+ cchar_t ch;
+ SCREEN *sp;
+
+ AssertTCB();
+
+ if (TCB == 0 || InvalidConsoleHandle(TCB->hdl))
+ return FALSE;
+
+ SetSP();
+
+ for (i = 0; i < n; i++) {
+ ch = str[i];
+ ci[i].Char.UnicodeChar = CharOf(ch);
+ ci[i].Attributes = MapAttr(TCB,
+ PropOf(TCB)->SBI.wAttributes,
+ AttrOf(ch));
+ if (AttrOf(ch) & A_ALTCHARSET) {
+ if (_nc_wacs) {
+ int which = CharOf(ch);
+ if (which > 0
+ && which < ACS_LEN
+ && CharOf(_nc_wacs[which]) != 0) {
+ ci[i].Char.UnicodeChar = CharOf(_nc_wacs[which]);
+ } else {
+ ci[i].Char.UnicodeChar = ' ';
+ }
+ }
+ }
+ }
+
+ loc.X = (short) 0;
+ loc.Y = (short) 0;
+ siz.X = (short) n;
+ siz.Y = 1;
+
+ rec.Left = (short) x;
+ rec.Top = (short) y;
+ rec.Right = (short) (x + n - 1);
+ rec.Bottom = rec.Top;
+
+ return WriteConsoleOutputW(TCB->hdl, ci, siz, loc, &rec);
+}
+#define con_write(tcb, y, x, str, n) con_write16(tcb, y, x, str, n)
+#else