Skip to content

Wide-issue and WT_SESSION #341

@gvanem

Description

@gvanem

I've made a little test-program for UTF-8 encoded strings. The gist of it:

/**
 * Check the UTF-8 output of 2 airports.
 *
 * "KEF" should translate to "Reykjavik" with an acute 'i'; U+00ED, as hex "C3 AD"
 * https://www.compart.com/en/unicode/U+00ED
 *
 * "ENFL" should translate to "Floro" with stoke across the 'o'; U+00F8, as hex "C3 B8"
 * https://www.compart.com/en/unicode/U+00F8
 */
static void test_utf8 (void)
{
  const char    *KEF1 =  "Reykjav\xC3\xADk";  /* UTF-8 encoding */
  const wchar_t *KEF2 = L"Reykjav\xEDk";      /* UTF-16 encoding */
  const char    *FLO1 =  "Flor\xC3\xB8";      /* UTF-8 encoding */
  const wchar_t *FLO2 = L"Flor\xF8";          /* UTF-16 encoding */
  int   y;

  if (Modes.tui_interface == TUI_CURSES)
       y = getcury (stdscr);
  else y = con_info_out.dwCursorPosition.Y;

  (*api->print_format) (0, y++, "Using TUI=%s, locale: %s",
                        Modes.tui_interface == TUI_CURSES ? "Curses" : "WinCon",
                        setlocale (LC_ALL, NULL));

  (*api->print_format) (0, y++, "KEF1: '%s'\n"
                                "FLO1: '%s'", KEF1, FLO1);
  y++;

  (*api->print_wformat) (0, y++, L"KEF2: '%s'\n"
                                  "FLO2: '%s'", KEF2, FLO2);
  y += 2;

  (*api->print_wformat) (0, y++, L"Wide:  %-20.20s: %S", KEF2, hex_dump(KEF2, 2*wcslen(KEF2)));
  (*api->print_wformat) (0, y++, L"Wide:  %-20.20s: %S", FLO2, hex_dump(FLO2, 2*wcslen(FLO2)));

  y++;
  (*api->print_format) (0, y++, "ASCII: %-20.20s: %s", KEF1, hex_dump(KEF1, strlen(KEF1)));
  (*api->print_format) (0, y++, "ASCII: %-20.20s: %s", FLO1, hex_dump(FLO1, strlen(FLO1)));
}

The *api->print_format and *api->print_wformat are just func-pointers set to either plain WinCon or PDCurses-mod
functions at runtime.

With a set WT_SESSION=1 before running, it display just fine:
Image

But w/o a set WT_SESSION=1, it looks like this:

Image

I've tried with setlocale (LC_ALL, ".utf8"); and/or SetConsoleOutputCP (CP_UTF8); w/o much difference. Only
this strange set WT_SESSION=1 fixes it.

So what is this and pdc_wt all about?

And BTW, I'm on Win-10 using TakeCommand as my shell.
No Leagacy Console and UTF-8 set in some Windows setting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions