aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/text.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/data/text.lux')
-rw-r--r--stdlib/source/lux/data/text.lux46
1 files changed, 13 insertions, 33 deletions
diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux
index ad33c67ac..dca74423c 100644
--- a/stdlib/source/lux/data/text.lux
+++ b/stdlib/source/lux/data/text.lux
@@ -134,39 +134,19 @@
(open Monoid<Text>)
-(struct: #export _ (Codec Text Text)
- (def: (encode original)
- (let [escaped (|> original
- (replace-all "\\" "\\\\")
- (replace-all "\t" "\\t")
- (replace-all "\v" "\\v")
- (replace-all "\b" "\\b")
- (replace-all "\n" "\\n")
- (replace-all "\r" "\\r")
- (replace-all "\f" "\\f")
- (replace-all "\"" "\\\"")
- )]
- ($_ append "\"" escaped "\"")))
-
- (def: (decode input)
- (if (and (starts-with? "\"" input)
- (ends-with? "\"" input))
- (case (clip +1 (n.dec (size input)) input)
- (#;Some input')
- (|> input'
- (replace-all "\\\\" "\\")
- (replace-all "\\t" "\t")
- (replace-all "\\v" "\v")
- (replace-all "\\b" "\b")
- (replace-all "\\n" "\n")
- (replace-all "\\r" "\r")
- (replace-all "\\f" "\f")
- (replace-all "\\\"" "\"")
- #;Some)
-
- #;None
- (#;Left "Could not decode text"))
- (#;Left "Could not decode text"))))
+(def: #export (encode original)
+ (-> Text Text)
+ (let [escaped (|> original
+ (replace-all "\\" "\\\\")
+ (replace-all "\t" "\\t")
+ (replace-all "\v" "\\v")
+ (replace-all "\b" "\\b")
+ (replace-all "\n" "\\n")
+ (replace-all "\r" "\\r")
+ (replace-all "\f" "\\f")
+ (replace-all "\"" "\\\"")
+ )]
+ ($_ append "\"" escaped "\"")))
(struct: #export _ (Hash Text)
(def: eq Eq<Text>)