Skip to content

Bugfix: fix overshoot with wide characters #569 - #668

Open
6f7665 wants to merge 2 commits into
ncmpcpp:masterfrom
6f7665:fix_wide_char_overshoot_569
Open

6f7665 wants to merge 2 commits into
ncmpcpp:masterfrom
6f7665:fix_wide_char_overshoot_569

Conversation

@6f7665

@6f7665 6f7665 commented Sep 29, 2026

Copy link
Copy Markdown

Issue:
#569

Description:
Japanese characters in song names used to cause an overshoot of the song-lenght. {$R(%l)} for example would then be offset by the wide characters and the closing mark would print at the start of the row. This would occur in the playlist editor mostly.

Cause:
If mvaddwstr(0,0,L"日本語") is called first and then mvaddwstr(0,1,L"Hello"), the expected output should be " Hello", but since ncurses appends on the started character that is two columns it turns into "日Hello". One must thus use mvaddwstr(0,0,L" Hello") in order to overwrite correctly.

Fix:
The bug is fixed by checking if text is going to be printed in the middle of a wide character, if it is going to print inside a wide character the string starts one col earlier and is suffixed by three dots '…' (Horizontal ellipsis, U+2026).

Before (left) and after (right):
2026-09-29-131638_bug_fix_569_ncmpcpp

Note:
This fix adds a function called isInsideWideChar(), but it is only called from Window &Window::operator<<(const std::string &s) currently, as the main view (1), uses wstring, but maybe it could be changed into a cutWideChar() function and then called from all the overloaded operator functions that print to the screen, however, since the main view uses wideCut() from src/utility/wide_string.cpp it should not be needed and would just add extra cycles to the cpu. A possible improvement could however be to only call cutWideChar before sending strings with << when needed. But that would require checking all the operators '<<' and checking if they print to screen and if it is needed to run a cutWideChar() function.

Issue:
ncmpcpp#569

Japanese characters in song names used to cause an overshoot of the
song-lenght. {$R(%l)} for example would then be offset by the wide
characters and the closing mark would print at the start of the row.

The bug is fixed by checking if text is going to be printed on top of
wide characters, then adjusting so that the string starts one col
earlier and is suffixed by a dot.

This is because if mvaddwstr(0,0,L"日本語") is called first and then
mvaddwstr(0,1,L"Hello"), the expected output should be " Hello", but
since ncurses appends on the started character that is two columns it
turns into "日Hello". One must thus use mvaddwstr(0,0,L" Hello") in
order to overwrite correctly.
@6f7665
6f7665 force-pushed the fix_wide_char_overshoot_569 branch from a2f1e13 to e435136 Compare October 5, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant