# HG changeset patch # User Pantxo Diribarne # Date 1559600772 -7200 # Node ID 8a07083c8cfc9044aa3f2b55290fd1dcbce14c38 # Parent 8854d65e3bccb1f70cf4614773ce5242ca624d9f Use replacement characters to display non UTF-8 strings in figures (bug #55974) * contributors.in: Add Imad-Eddine Srairi who found the origin of the bug and provided the fix. * ft-text-renderer.cc (ft_text_renderer::visit): Use replacement character for unhandled (non-UTF-8) characters. * gl2ps-print.cc (gl2ps_renderer::strlist_to_ps): Use question mark for multibyte and non-ascii characters. diff -r 8854d65e3bcc -r 8a07083c8cfc doc/interpreter/contributors.in --- a/doc/interpreter/contributors.in Thu May 30 11:35:51 2019 +0200 +++ b/doc/interpreter/contributors.in Tue Jun 04 00:26:12 2019 +0200 @@ -373,6 +373,7 @@ Quentin H. Spencer Christoph Spiel David Spies +Imad-Eddine Srairi Andreas Stahel Richard Stallman Russell Standish diff -r 8854d65e3bcc -r 8a07083c8cfc libinterp/corefcn/ft-text-renderer.cc --- a/libinterp/corefcn/ft-text-renderer.cc Thu May 30 11:35:51 2019 +0200 +++ b/libinterp/corefcn/ft-text-renderer.cc Tue Jun 04 00:26:12 2019 +0200 @@ -902,6 +902,13 @@ // Retrieve the length and the u32 representation of the current // character int mblen = octave_u8_strmbtouc_wrapper (&u32_c, c + icurr); + if (mblen < 1) + { + // This is not an UTF-8 character, use a replacement character + mblen = 1; + u32_c = 0xFFFD; + } + n -= mblen; if (m_do_strlist && mode == MODE_RENDER) diff -r 8854d65e3bcc -r 8a07083c8cfc libinterp/corefcn/gl2ps-print.cc --- a/libinterp/corefcn/gl2ps-print.cc Thu May 30 11:35:51 2019 +0200 +++ b/libinterp/corefcn/gl2ps-print.cc Tue Jun 04 00:26:12 2019 +0200 @@ -928,9 +928,10 @@ { int mblen = octave_u8_strmblen_wrapper (c + i); + // Replace multibyte or non ascii characters by a question mark if (mblen > 1) { - str += " "; + str += "?"; if (! warned) { warning_with_id ("Octave:print:unsupported-multibyte", @@ -940,6 +941,19 @@ warned = true; } } + else if (mblen < 1) + { + mblen = 1; + str += "?"; + if (! warned) + { + warning_with_id ("Octave:print:unhandled-character", + "print: only ASCII characters are " + "supported for EPS and derived " + "formats."); + warned = true; + } + } else str += tmpstr.at (i);