Repository navigation
Conversation
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
force-pushed
the
fix_wide_char_overshoot_569
branch
from
October 5, 2026 14:26
a2f1e13 to
e435136
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):

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.