From 1ea478858573045e5d3e3f8ccc3773021ea68ffa Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 8 May 2019 17:16:59 +0200 Subject: Implement normalization of missing builtins --- dhall_syntax/src/printer.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'dhall_syntax') diff --git a/dhall_syntax/src/printer.rs b/dhall_syntax/src/printer.rs index e3b180b..ebc9770 100644 --- a/dhall_syntax/src/printer.rs +++ b/dhall_syntax/src/printer.rs @@ -250,12 +250,23 @@ impl Display for InterpolatedText { match c { '\\' => f.write_str("\\\\"), '"' => f.write_str("\\\""), - '$' => f.write_str("\\$"), + '$' => f.write_str("\\u0024"), '\u{0008}' => f.write_str("\\b"), '\u{000C}' => f.write_str("\\f"), '\n' => f.write_str("\\n"), '\r' => f.write_str("\\r"), '\t' => f.write_str("\\t"), + '\u{0000}'..='\u{001F}' => { + // Escape to an explicit "\u{XXXX}" form + let escaped: String = + c.escape_default().collect(); + // Print as "\uXXXX" + write!( + f, + "\\u{:0>4}", + &escaped[3..escaped.len() - 1] + ) + } c => write!(f, "{}", c), }?; } -- cgit v1.2.3