$ TEST="$(echo "\u100")" gleam run
Compiled in 0.01s
Running vars.main
exception error: bad argument
in function list_to_binary/1
called as list_to_binary([256])
*** argument 1: not an iolist term
in call from envoy_ffi:get/1 (/Users/tim/Projects/sandbox/gleam/vars/build/dev/erlang/envoy/_gleam_artefacts/envoy_ffi.erl, line 8)
in call from vars:main/0 (/Users/tim/Projects/sandbox/gleam/vars/build/dev/erlang/vars/_gleam_artefacts/vars.erl, line 8)
Notes
If running bash version <4.2 before \u was supported, you can use TEST="$(printf '\xc4\x80')" gleam run to get an environment variable with value \u100.
This problem occurs with any characters with value >255. I'm not familiar with the Erlang stdlib, but from looking around a bit it seems that os:getenv doesn't always return something that can be considered an iolist, presumably because the character code points don't fit into a single byte. I'm not sure what the output needs to be wrapped in to properly transform the string returned by os:getenv to the Gleam String returned by get, but please let me know if I can be of any assistance!
Hello!
I'm having trouble with Unicode characters in my environment variables.
Steps to Reproduce
vars.gleam
Shell
Notes
If running bash version <4.2 before
\u
was supported, you can useTEST="$(printf '\xc4\x80')" gleam run
to get an environment variable with value\u100
.This problem occurs with any characters with value >255. I'm not familiar with the Erlang stdlib, but from looking around a bit it seems that
os:getenv
doesn't always return something that can be considered aniolist
, presumably because the character code points don't fit into a single byte. I'm not sure what the output needs to be wrapped in to properly transform the string returned byos:getenv
to the GleamString
returned byget
, but please let me know if I can be of any assistance!Loving Gleam, btw! Thanks a bunch!