aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Puc <marcin.e.puc@gmail.com>2021-05-10 19:27:56 +0200
committerLouis Pilfold <louis@lpil.uk>2021-05-12 11:35:10 +0100
commitd1f38c1b92f332ff338426ed7b50c3841245a617 (patch)
tree0a8b429b6be4b675918eb36447348327449e41a2
parent931d4544510afa4d879ef6c5e52f4750d0812f45 (diff)
downloadgleam_stdlib-d1f38c1b92f332ff338426ed7b50c3841245a617.tar.gz
gleam_stdlib-d1f38c1b92f332ff338426ed7b50c3841245a617.zip
Support unicode in env variables
-rw-r--r--src/gleam/os.gleam4
-rw-r--r--test/gleam/os_test.gleam7
2 files changed, 9 insertions, 2 deletions
diff --git a/src/gleam/os.gleam b/src/gleam/os.gleam
index 374c5e2..fcaf724 100644
--- a/src/gleam/os.gleam
+++ b/src/gleam/os.gleam
@@ -17,10 +17,10 @@ external fn os_unsetenv(key: CharList) -> Bool =
"os" "unsetenv"
external fn char_list_to_string(CharList) -> String =
- "erlang" "list_to_binary"
+ "unicode" "characters_to_binary"
external fn string_to_char_list(String) -> CharList =
- "erlang" "binary_to_list"
+ "unicode" "characters_to_list"
/// Returns all environment variables set on the system.
pub fn get_env() -> Map(String, String) {
diff --git a/test/gleam/os_test.gleam b/test/gleam/os_test.gleam
index 6385453..3442a90 100644
--- a/test/gleam/os_test.gleam
+++ b/test/gleam/os_test.gleam
@@ -15,6 +15,13 @@ pub fn env_test() {
|> should.equal(Error(Nil))
}
+pub fn unicode_test() {
+ os.insert_env("GLEAM_UNICODE_TEST", "Iñtërnâtiônà£ißætiøn☃💩")
+ os.get_env()
+ |> map.get("GLEAM_UNICODE_TEST")
+ |> should.equal(Ok("Iñtërnâtiônà£ißætiøn☃💩"))
+}
+
pub fn system_time_test() {
let june_12_2020 = 1591966971
{ os.system_time(os.Second) > june_12_2020 }