OpenWrt Forum Archive

Topic: [SOLVED] UTF8 support for Erlang?

The content of this topic has been archived on 25 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

I've tried many different ways when compiling the Erlang package to enable UTF8 support but each time it ends up using the latin char-set.

Things I've tried:
- export `LC_CTYPE and LC_ALL` with a value of `en_US.UTF-8` during compile time
- export the same vars above when running the interactive prompt

Erlang code used to test if UTF8 is enabled:

1> lists:keyfind(encoding, 1, io:getopts()).
2> io:format("~ts~n",["Paměť"]).

Returned values:

1> {encoding,latin1}
2> Pam\304\233\305\245
   ok

What else can I do to try and enable UTF8 support in Erlang?

(Last edited by camelCaseD on 2 Sep 2016, 21:07)

I am not sure if I can be of any help. However, according to this Using Unicode in Erlang, it says the encoding default for Erlang source files was switched to UTF-8 in Erlang/OTP 17.0. The current OpenWRT erlang package is version R17.5 and should have UTF-8, AFAICT.

@mazilo thanks for the answer but that only applies to the files and not the VM that Erlang code compiles down to and runs in.

Sorry, I can't be of any help on this. sad

After much digging around the Erlang docs I found out that I need set the env var of ERL_FLAGS to '+fnu' in the shell to enable UTF8 support in the Beam VM.

The discussion might have continued from here.