diff options
Diffstat (limited to 'stdlib/source/lux/data/text/encoding.lux')
-rw-r--r-- | stdlib/source/lux/data/text/encoding.lux | 17 |
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 |