Skip to content

Commit

Permalink
Handle backslash in lexis properly
Browse files Browse the repository at this point in the history
  • Loading branch information
lierdakil committed Aug 4, 2023
1 parent da4f436 commit d0f4631
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ indentLang indentSize n s = T.intercalate "\n" $ case T.lines s of
showChar' :: LangS -> Char -> Text
showChar' l c = case l of
CPP
| c == '\\' -> "\\\\"
| isAscii c -> if isPrint c then pack [c] else "\\x" <> hex c
| otherwise -> error "Non-ascii characters are unsupported in C++"
CSharp
| c == '\\' -> "\\\\"
| isPrint c -> pack [c]
| otherwise -> "\\U" <> hexU c
Python
| c == '\\' -> "\\\\"
| isPrint c -> pack [c]
| otherwise -> "\\U" <> hexU c
JS
| c == '\\' -> "\\\\"
| isPrint c -> pack [c]
| otherwise -> "\\u{" <> hexU c <> "}"

Expand Down

0 comments on commit d0f4631

Please sign in to comment.