Page MenuHomeFreeBSD

PR 274472 - bsddialog and PuTTY shows garbled graphics
ClosedPublic

Authored by asiciliano on Oct 27 2023, 1:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 13, 8:16 PM
Unknown Object (File)
Mon, May 13, 6:36 PM
Unknown Object (File)
Mon, May 13, 4:24 PM
Unknown Object (File)
Fri, May 3, 7:36 PM
Unknown Object (File)
Fri, Apr 26, 2:09 AM
Unknown Object (File)
Apr 20 2024, 9:47 AM
Unknown Object (File)
Feb 22 2024, 12:56 AM
Unknown Object (File)
Jan 10 2024, 10:03 PM
Subscribers

Details

Summary

PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274472

I can reproduce the problem with putty (from PORTS) on FreeBSD 15.0-CURRENT amd64 GENERIC 1500001 (built Thu Oct 12 12:03:48 CEST 2023). So I investigated. Actually the problem starts from ncurses, just a simple test to reproduce

#include <curses.h>
#include <locale.h>

int main()
{
	char *locale;

	locale = setlocale(LC_ALL, "");
	initscr();

	box(stdscr, 0, 0);

	mvprintw(2, 2, "locale: %s.", locale);
	mvaddstr(3, 2, "1) locale encode: あいうえお");
	mvaddwstr(4, 2, L"2) wide char: あいうえお");

	mvaddstr(5, 2, "3) box-drawing chars (ACS_*): ");
	addch(ACS_VLINE); addch(' ');
	addch(ACS_HLINE); addch(' ');
	addch(ACS_ULCORNER); addch(' ');
	addch(ACS_URCORNER); addch(' ');
	addch(ACS_LRCORNER); addch(' ');
	addch(ACS_LLCORNER); addch(' ');
	addch(ACS_RTEE); addch(' ');
	addch(ACS_LTEE); addch(' ');
	
	mvaddstr(7, 3, "<Press a key to close>");
	refresh();
	getch();
	endwin();

	return (0);
}

% cc -D_XOPEN_SOURCE_EXTENDED acs_test.c -o acs_test -lncursesw
% ./acs_test

Output:

{F70055668}

Japanese chars are OK, while "box-drawing chars (ACS_*)" and the box around the screen are not rendered correctly. Of course all ncurses clients are affected, for example, LGPL dialog(1) on my old laptop with FreeBSD 13.0-ALPHA (built 2021).

{F70055796}

Actually the problem seems a (documented) feature of ncurses, 'env NCURSES_NO_UTF8_ACS' https://invisible-island.net/ncurses/man/ncurses.3x.html#h3-NCURSES_NO_UTF8_ACS. So % env NCURSES_NO_UTF8_ACS=1 ./acs_test solves the problem:

{F70055869}

Googling "putty ncurses" a lot of discuission exist (ncurses maintainer gives some suggestion). I just link https://superuser.com/questions/278286/making-256-color-and-line-drawing-characters-both-work-in-putty because the first comment describes briefly the problem with putty and the "official" solution from its developers Window -> Translation -> [X] Enable VT100 line drawing even in UTF-8 mode:

{F70055918}

Of course env NCURSES_NO_UTF8_ACS=1 is unnecessary now, just % ./acs_test:

{F70055955}

Solution.

We could create a wiki page or something in the handbook to describe the 2 "official" solution (Enable VT100 line drawing even in UTF-8 mode or NCURSES_NO_UTF8_ACS=1).

Other Solutions

I can add to libbsddialog setenv(NCURSES_NO_UTF8_ACS, 1, 1).

We could add "U8" capability (ncurses manual above).

We can patch ncurses (NCURSES_NO_UTF8_ACS) in BASE https://cgit.freebsd.org/src/tree/contrib/ncurses/ncurses/tinfo/lib_setup.c#n598

Preference? Other solution?
I have revived my old laptop, so I'll install and test with 12.* and 13.*.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

New solution.

Change box-drawing characters in libbsddialog: from utf8 to wide chars.

This revision was not accepted when it landed; it landed in state Needs Review.Thu, May 16, 1:27 PM
This revision was automatically updated to reflect the committed changes.