diff options
author | Richard Viney <richard.viney@gmail.com> | 2024-05-11 10:35:36 +1200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2024-05-13 14:30:39 +0100 |
commit | ef4731e081fbcc937b2d52805943528d898ab39f (patch) | |
tree | 13b8e6d6555a32b4081452bc9a76da603a4334b3 | |
parent | 61a990b147d199b737295c288977b95f4cc285b8 (diff) | |
download | gleam_stdlib-ef4731e081fbcc937b2d52805943528d898ab39f.tar.gz gleam_stdlib-ef4731e081fbcc937b2d52805943528d898ab39f.zip |
Escape form feed control character in string.inspect on Erlang
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | src/gleam_stdlib.erl | 1 | ||||
-rw-r--r-- | test/gleam/string_test.gleam | 3 |
3 files changed, 6 insertions, 0 deletions
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 -> <<Other/utf8>> end, inspect_maybe_utf8_string(Rest, <<Acc/binary, Escaped/binary>>); 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\"") |