diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/data/text/encoding.lux | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/stdlib/source/lux/data/text/encoding.lux b/stdlib/source/lux/data/text/encoding.lux index a081233c9..7445d5ebc 100644 --- a/stdlib/source/lux/data/text/encoding.lux +++ b/stdlib/source/lux/data/text/encoding.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["@" target] - ["." host] + ["." ffi] [abstract [codec (#+ Codec)]] [control @@ -169,7 +169,7 @@ (|>> :representation)) ) -(with_expansions [<jvm> (as_is (host.import: java/lang/String +(with_expansions [<jvm> (as_is (ffi.import: java/lang/String ["#::." (new [[byte] java/lang/String]) (getBytes [java/lang/String] [byte])]))] @@ -177,42 +177,42 @@ @.jvm (as_is <jvm>) @.js - (as_is (host.import: Uint8Array) + (as_is (ffi.import: Uint8Array) ## On Node - (host.import: Buffer - (#static from #as from|encode [host.String host.String] Buffer) + (ffi.import: Buffer + (#static from #as from|encode [ffi.String ffi.String] Buffer) (#static from #as from|decode [Uint8Array] Buffer) - (toString [host.String] host.String)) + (toString [ffi.String] ffi.String)) ## On the browser - (host.import: TextEncoder - (new [host.String]) - (encode [host.String] Uint8Array)) + (ffi.import: TextEncoder + (new [ffi.String]) + (encode [ffi.String] Uint8Array)) - (host.import: TextDecoder - (new [host.String]) - (decode [Uint8Array] host.String))) + (ffi.import: TextDecoder + (new [ffi.String]) + (decode [Uint8Array] ffi.String))) @.ruby - (as_is (host.import: String #as RubyString + (as_is (ffi.import: String #as RubyString (encode [Text] RubyString) (force_encoding [Text] Text) (bytes [] Binary)) - (host.import: Array #as RubyArray + (ffi.import: Array #as RubyArray (pack [Text] RubyString))) @.php - (as_is (host.import: Almost_Binary) - (host.import: (unpack [host.String host.String] Almost_Binary)) - (host.import: (array_values [Almost_Binary] Binary)) + (as_is (ffi.import: Almost_Binary) + (ffi.import: (unpack [ffi.String ffi.String] Almost_Binary)) + (ffi.import: (array_values [Almost_Binary] Binary)) (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 (ffi.import: (string->utf8 [Text] Binary)) + (ffi.import: (utf8->string [Binary] Text)))} (as_is))) (def: (utf8\encode value) @@ -229,10 +229,10 @@ (java/lang/String::getBytes (..name ..utf_8) value) @.js - (cond host.on_nashorn? + (cond ffi.on_nashorn? (:coerce Binary ("js object do" "getBytes" value ["utf8"])) - host.on_node_js? + ffi.on_node_js? (|> (Buffer::from|encode [value "utf8"]) ## This coercion is valid as per NodeJS's documentation: ## https://nodejs.org/api/buffer.html#buffer_buffers_and_typedarrays @@ -271,12 +271,12 @@ @.jvm <jvm> @.js - (cond host.on_nashorn? + (cond ffi.on_nashorn? (|> ("js object new" ("js constant" "java.lang.String") [value "utf8"]) (:coerce Text) #try.Success) - host.on_node_js? + ffi.on_node_js? (|> (Buffer::from|decode [value]) (Buffer::toString ["utf8"]) #try.Success) @@ -287,7 +287,7 @@ #try.Success)) @.python - (host.try (:coerce Text ("python object do" "decode" (:assume value) "utf-8"))) + (ffi.try (:coerce Text ("python object do" "decode" (:assume value) "utf-8"))) @.lua (#try.Success ("lua utf8 decode" value)) |