From 86538182a50390e7882778cc02e69482e846edd5 Mon Sep 17 00:00:00 2001
From: Eduardo Julian
Date: Mon, 24 May 2021 11:23:40 -0400
Subject: Almost done with Scheme.

But will have to postpone finishing it because Kawa is not up to snuff.---
 stdlib/source/lux/data/text/encoding.lux | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

(limited to 'stdlib/source/lux/data/text/encoding.lux')

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
-- 
cgit v1.2.3