[Webkit-unassigned] [Bug 214180] [GTK] MiniBrowser: title of back-forward menu items needs to be truncated when it's too large
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Jul 10 12:41:01 PDT 2020
https://bugs.webkit.org/show_bug.cgi?id=214180
--- Comment #4 from Adrian Perez <aperez at igalia.com> ---
Comment on attachment 403956
--> https://bugs.webkit.org/attachment.cgi?id=403956
Patch
View in context: https://bugs.webkit.org/attachment.cgi?id=403956&action=review
>> Tools/MiniBrowser/gtk/BrowserWindow.c:235
>> + displayTitle[MAX_TITLE - 1] = '.';
>
> I would use an actual ellipsis character (“…”, U+2026) which in
> UTF-8 is the sequence of bytes 0xE2, 0x80, 0xA6:
>
> displayTitle[MAX_TITLE - 3] = 0xE2;
> displayTitle[MAX_TITLE - 2] = 0x80;
> displayTitle[MAX_TITLE - 1] = 0xA6;
>
> ️
I just had a sudden realization: If the “MAX_TITLE - 3” index falls
in the middle of an UTF-8 multi byte sequence, the string resulting
from ellipsizing this way results in an invalid UTF-8 string.
Dunno if there is a better option, but one idea would be to use
g_utf8_offset_to_pointer(displayTitle, MAX_TITLE - 3) to find out
the corresponding byte offset for the amount of *Unicode* characters
(not bytes) we want to show before the ellipsis, and then append the
ellipsis there.
Sorry for not noticing this earlier.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200710/100a7a05/attachment.htm>
More information about the webkit-unassigned
mailing list