Skip to content

Commit d1f38c1

Browse files
tranzystorekklpil
authored andcommitted
Support unicode in env variables
1 parent 931d454 commit d1f38c1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/gleam/os.gleam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ external fn os_unsetenv(key: CharList) -> Bool =
1717
"os" "unsetenv"
1818

1919
external fn char_list_to_string(CharList) -> String =
20-
"erlang" "list_to_binary"
20+
"unicode" "characters_to_binary"
2121

2222
external fn string_to_char_list(String) -> CharList =
23-
"erlang" "binary_to_list"
23+
"unicode" "characters_to_list"
2424

2525
/// Returns all environment variables set on the system.
2626
pub fn get_env() -> Map(String, String) {

test/gleam/os_test.gleam

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ pub fn env_test() {
1515
|> should.equal(Error(Nil))
1616
}
1717

18+
pub fn unicode_test() {
19+
os.insert_env("GLEAM_UNICODE_TEST", "Iñtërnâtiônà£ißætiøn☃💩")
20+
os.get_env()
21+
|> map.get("GLEAM_UNICODE_TEST")
22+
|> should.equal(Ok("Iñtërnâtiônà£ißætiøn☃💩"))
23+
}
24+
1825
pub fn system_time_test() {
1926
let june_12_2020 = 1591966971
2027
{ os.system_time(os.Second) > june_12_2020 }

0 commit comments

Comments
 (0)