lib: quoteIfNeeded should not escape the backslashes in unicode code points.
This commit is contained in:
parent
08ee311875
commit
97545018f4
@ -118,13 +118,17 @@ underline s = s' ++ replicate (length s) '-' ++ "\n"
|
|||||||
-- | Double-quote this string if it contains whitespace, single quotes
|
-- | Double-quote this string if it contains whitespace, single quotes
|
||||||
-- or double-quotes, escaping the quotes as needed.
|
-- or double-quotes, escaping the quotes as needed.
|
||||||
quoteIfNeeded :: String -> String
|
quoteIfNeeded :: String -> String
|
||||||
quoteIfNeeded s | any (`elem` s) (quotechars++whitespacechars++redirectchars) = show s
|
quoteIfNeeded s | any (`elem` s) (quotechars++whitespacechars++redirectchars) = showChar '"' $ escapeQuotes s "\""
|
||||||
| otherwise = s
|
| otherwise = s
|
||||||
|
where
|
||||||
|
escapeQuotes [] x = x
|
||||||
|
escapeQuotes ('"':cs) x = showString "\\\"" $ escapeQuotes cs x
|
||||||
|
escapeQuotes (c:cs) x = showChar c $ escapeQuotes cs x
|
||||||
|
|
||||||
-- | Single-quote this string if it contains whitespace or double-quotes.
|
-- | Single-quote this string if it contains whitespace or double-quotes.
|
||||||
-- No good for strings containing single quotes.
|
-- No good for strings containing single quotes.
|
||||||
singleQuoteIfNeeded :: String -> String
|
singleQuoteIfNeeded :: String -> String
|
||||||
singleQuoteIfNeeded s | any (`elem` s) whitespacechars = "'"++s++"'"
|
singleQuoteIfNeeded s | any (`elem` s) (quotechars++whitespacechars) = "'"++s++"'"
|
||||||
| otherwise = s
|
| otherwise = s
|
||||||
|
|
||||||
quotechars, whitespacechars, redirectchars :: [Char]
|
quotechars, whitespacechars, redirectchars :: [Char]
|
||||||
|
|||||||
@ -6,3 +6,12 @@ hledger -f - register τράπ
|
|||||||
>>>
|
>>>
|
||||||
2009-01-01 проверка τράπεζα 10 руб 10 руб
|
2009-01-01 проверка τράπεζα 10 руб 10 руб
|
||||||
>>>=0
|
>>>=0
|
||||||
|
|
||||||
|
hledger -f - balance -N " ét"
|
||||||
|
<<<
|
||||||
|
2020-09-19 Test
|
||||||
|
assets:a ét 5
|
||||||
|
assets:b
|
||||||
|
>>>
|
||||||
|
5 assets:a ét
|
||||||
|
>>>=0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user