From: Mattias EngdegÄrd Date: Fri, 21 Aug 2020 14:09:04 +0000 (+0200) Subject: Always make a multibyte string for the frame title (bug#42904) X-Git-Tag: emacs-28.0.90~6443 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a5394884627db6f6091c4b85b635af81c20f0f31;p=emacs.git Always make a multibyte string for the frame title (bug#42904) * src/xdisp.c (gui_consider_frame_title): Multibyte-encode any raw bytes in the title, and then pass a multibyte string to the back-end for use as a frame title. This cuts down a little on the rubbish shown when raw bytes sneak in by mistake (as part of the buffer name, for instance). --- diff --git a/src/xdisp.c b/src/xdisp.c index 34644dff39c..e2ebbbdce72 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -12565,6 +12565,11 @@ gui_consider_frame_title (Lisp_Object frame) display_mode_element (&it, 0, -1, -1, fmt, Qnil, false); len = MODE_LINE_NOPROP_LEN (title_start); title = mode_line_noprop_buf + title_start; + /* Make sure that any raw bytes in the title are properly + represented by their multibyte sequences. */ + ptrdiff_t nchars = 0; + len = str_as_multibyte (title, mode_line_noprop_buf_end - title, + len, &nchars); unbind_to (count, Qnil); /* Set the title only if it's changed. This avoids consing in @@ -12576,9 +12581,10 @@ gui_consider_frame_title (Lisp_Object frame) || SBYTES (f->name) != len || memcmp (title, SDATA (f->name), len) != 0) && FRAME_TERMINAL (f)->implicit_set_name_hook) - FRAME_TERMINAL (f)->implicit_set_name_hook (f, - make_string (title, len), - Qnil); + { + Lisp_Object title_string = make_multibyte_string (title, nchars, len); + FRAME_TERMINAL (f)->implicit_set_name_hook (f, title_string, Qnil); + } } }