diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 4fbe0176c57c1bbf142a166b1384015dce5555f7..13c310c4df27fc8c320205320bae74beac49101c 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -3014,6 +3014,15 @@ i	j
 6	3
 DROP VIEW v1, v2;
 DROP TABLE t1;
+DROP VIEW IF EXISTS v1;
+CREATE VIEW v1 AS SELECT 'The\ZEnd';
+SELECT * FROM v1;
+TheEnd
+TheEnd
+SHOW CREATE VIEW v1;
+View	Create View
+v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'The\ZEnd' AS `TheEnd`
+DROP VIEW v1;
 End of 5.0 tests.
 DROP DATABASE IF EXISTS `d-1`;
 CREATE DATABASE `d-1`;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 7175db1db4e4b98c7d196df56e2a00d82f300dc6..10ebfcfb697d46a2a707c83bf62f8c0d70ce2774 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -2906,6 +2906,7 @@ DROP FUNCTION f1;
 DROP VIEW v1;
 DROP TABLE t1;
 
+#
 # Bug #16813 (WITH CHECK OPTION doesn't work with UPDATE)
 #
 CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT NULL);
@@ -2919,7 +2920,6 @@ UPDATE v1 SET val=6 WHERE id=2;
 DROP VIEW v1;
 DROP TABLE t1;
 
-
 #
 # BUG#22584: last_insert_id not updated after inserting a record
 # through a updatable view
@@ -2957,6 +2957,20 @@ SELECT * FROM t1;
 DROP VIEW v1, v2;
 DROP TABLE t1;
 
+#
+# BUG#24293: '\Z' token is not handled correctly in views
+#
+
+--disable_warnings
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+CREATE VIEW v1 AS SELECT 'The\ZEnd';
+SELECT * FROM v1;
+
+SHOW CREATE VIEW v1;
+
+DROP VIEW v1;
 
 --echo End of 5.0 tests.
 
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index b307953addccec966ae00ba368bbee4d6b33db19..2aaab83796f1af40d923ad4bdcf23fd4f53a39f9 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -1022,8 +1022,8 @@ void String::print(String *str)
     case '\r':
       str->append(STRING_WITH_LEN("\\r"));
       break;
-    case 26: //Ctrl-Z
-      str->append(STRING_WITH_LEN("\\z"));
+    case '\032': // Ctrl-Z
+      str->append(STRING_WITH_LEN("\\Z"));
       break;
     default:
       str->append(c);