aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/text/encoding.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-05-24 11:23:40 -0400
committerEduardo Julian2021-05-24 11:23:40 -0400
commit86538182a50390e7882778cc02e69482e846edd5 (patch)
tree5f2b5800d4f9bd63355d78bc541110aaf0c6b134 /stdlib/source/lux/data/text/encoding.lux
parent20a3f2650e2e72b5f4e525bee8a6354a711f575b (diff)
Almost done with Scheme.
But will have to postpone finishing it because Kawa is not up to snuff.
Diffstat (limited to 'stdlib/source/lux/data/text/encoding.lux')
-rw-r--r--stdlib/source/lux/data/text/encoding.lux17
1 files changed, 15 insertions, 2 deletions
diff --git a/stdlib/source/lux/data/text/encoding.lux b/stdlib/source/lux/data/text/encoding.lux
index 3296f78c4..a081233c9 100644
--- a/stdlib/source/lux/data/text/encoding.lux
+++ b/stdlib/source/lux/data/text/encoding.lux
@@ -207,7 +207,12 @@
(as_is (host.import: Almost_Binary)
(host.import: (unpack [host.String host.String] Almost_Binary))
(host.import: (array_values [Almost_Binary] Binary))
- (def: php_byte_array_format "C*"))}
+ (def: php_byte_array_format "C*"))
+
+ @.scheme
+ ## https://srfi.schemers.org/srfi-140/srfi-140.html
+ (as_is (host.import: (string->utf8 [Text] Binary))
+ (host.import: (utf8->string [Binary] Text)))}
(as_is)))
(def: (utf8\encode value)
@@ -254,7 +259,10 @@
(|> (..unpack [..php_byte_array_format value])
..array_values
("php object new" "ArrayObject")
- (:coerce Binary))}))
+ (:coerce Binary))
+
+ @.scheme
+ (..string->utf8 value)}))
(def: (utf8\decode value)
(-> Binary (Try Text))
@@ -295,6 +303,11 @@
@.php
(|> value
("php pack" ..php_byte_array_format)
+ #try.Success)
+
+ @.scheme
+ (|> value
+ ..utf8->string
#try.Success)})))
(structure: #export utf8