Skip to content

Commit

Permalink
Escape form feed control character in string.inspect on Erlang
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-viney authored and lpil committed May 13, 2024
1 parent 61a990b commit ef4731e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/gleam_stdlib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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>>);
Expand Down
3 changes: 3 additions & 0 deletions test/gleam/string_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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\"")

Expand Down

0 comments on commit ef4731e

Please sign in to comment.