]> Repositorios git - scryer-prolog.git/commitdiff
extend logic to all control and whitespace characters
authorMarkus Triska <[email protected]>
Sun, 14 May 2023 07:14:10 +0000 (09:14 +0200)
committerMarkus Triska <[email protected]>
Sun, 14 May 2023 07:25:08 +0000 (09:25 +0200)
This addresses #1802.

src/heap_print.rs

index 635ae13cc1afc5c3b49ca1fc7a54c2e0b1e4d6a0..61477b1a29cdc8fa60a8f7acc204e04609f0f4fa 100644 (file)
@@ -169,13 +169,16 @@ fn char_to_string(is_quoted: bool, c: char) -> String {
         '\u{08}' if is_quoted => "\\b".to_string(), // UTF-8 backspace
         '\u{07}' if is_quoted => "\\a".to_string(), // UTF-8 alert
         '\\' if is_quoted => "\\\\".to_string(),
-        '\'' | '\n' | '\r' | '\t' | '\u{0b}' | '\u{0c}' | '\u{08}' | '\u{07}' | '"' | '\\' => {
+        ' ' | '\'' | '\n' | '\r' | '\t' | '\u{0b}' | '\u{0c}' | '\u{08}' | '\u{07}' | '"' | '\\' => {
             c.to_string()
         }
-        '\u{0}'..='\u{1f}' | '\u{7f}' ..= '\u{a0}'
-        // print all other control characters, and also non-breaking space, in hex.
-            => format!("\\x{:x}\\", c as u32),
-        _ => c.to_string(),
+        _ =>
+            if c.is_whitespace() || c.is_control() {
+                // print all other control and whitespace characters in hex.
+                format!("\\x{:x}\\", c as u32)
+            } else {
+                c.to_string()
+            }
     }
 }