From ef4731e081fbcc937b2d52805943528d898ab39f Mon Sep 17 00:00:00 2001 From: Richard Viney Date: Sat, 11 May 2024 10:35:36 +1200 Subject: Escape form feed control character in string.inspect on Erlang --- CHANGELOG.md | 2 ++ src/gleam_stdlib.erl | 1 + test/gleam/string_test.gleam | 3 +++ 3 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a61e116..da2c359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - The `list` module gains the `wrap` function. - The `iterator` module gains the `find_map` function. +- Fixed `string.inspect` not formatting the `\f` form feed control character + correctly on Erlang. ## v0.37.0 - 2024-04-19 diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl index b7d32ff..98cb695 100644 --- a/src/gleam_stdlib.erl +++ b/src/gleam_stdlib.erl @@ -497,6 +497,7 @@ inspect_maybe_utf8_string(Binary, Acc) -> $\r -> <<$\\, $r>>; $\n -> <<$\\, $n>>; $\t -> <<$\\, $t>>; + $\f -> <<$\\, $f>>; Other -> <> end, inspect_maybe_utf8_string(Rest, <>); diff --git a/test/gleam/string_test.gleam b/test/gleam/string_test.gleam index 684bc1b..4103f67 100644 --- a/test/gleam/string_test.gleam +++ b/test/gleam/string_test.gleam @@ -685,6 +685,9 @@ pub fn inspect_test() { string.inspect("\t") |> should.equal("\"\\t\"") + string.inspect("\f") + |> should.equal("\"\\f\"") + string.inspect("\r\r") |> should.equal("\"\\r\\r\"") -- cgit v1.2.3