Skip to content

Commit 1db2912

Browse files
authored
Fixed Issue #6929 Escape unicode when inspecting a Str
1 parent a58b101 commit 1db2912

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crates/compiler/builtins/roc/Inspect.roc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,15 @@ dbgStr = \s ->
258258
custom \f0 ->
259259
f0
260260
|> dbgWrite "\""
261-
|> dbgWrite s # TODO: Should we be escaping strings for dbg/logging?
261+
|> \f1 ->
262+
# escape invisible unicode characters
263+
escapeS = Str.replaceEach s "\u(feff)" "\\u(feff)"
264+
|> Str.replaceEach "\u(200b)" "\\u(200b)"
265+
|> Str.replaceEach "\u(200c)" "\\u(200c)"
266+
|> Str.replaceEach "\u(200d)" "\\u(200d)"
267+
dbgWrite f1 escapeS
262268
|> dbgWrite "\""
269+
263270

264271
dbgOpaque : * -> Inspector DbgFormatter
265272
dbgOpaque = \_ ->

0 commit comments

Comments
 (0)