diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 38b9fa6b353..fc016aeb345 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-09-27  Tom Tromey  <tom@tromey.com>
+
+	PR tui/25342:
+	* tui/tui-winsource.c (tui_copy_source_line): Use ISNCTRL.
+
 2020-09-27  Tom Tromey  <tom@tromey.com>
 
 	* unittests/tui-selftests.c: Update.
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 2300b9ab1e9..30b8f69027a 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -28,6 +28,7 @@
 #include "source.h"
 #include "objfiles.h"
 #include "filenames.h"
+#include "safe-ctype.h"
 
 #include "tui/tui.h"
 #include "tui/tui-data.h"
@@ -107,7 +108,9 @@ tui_copy_source_line (const char **ptr, int *length)
 	{
 	  /* Nothing.  */
 	}
-      else if (c < 040 && c != '\t')
+      else if (c == '\t')
+	process_tab ();
+      else if (ISCNTRL (c))
 	{
 	  result.push_back ('^');
 	  result.push_back (c + 0100);
@@ -119,8 +122,6 @@ tui_copy_source_line (const char **ptr, int *length)
 	  result.push_back ('?');
 	  ++column;
 	}
-      else if (c == '\t')
-	process_tab ();
       else
 	result.push_back (c);
     }