A1="Paměť". [80,97,109,283...">

How to output UTF-8 to Erlang shell?

Consider this snippet:

Eshell V5.9.1  (abort with ^G)
1> A="Pamet".
"Pamet"
2> A1="Paměť".
[80,97,109,283,357]

(“Paměť” is the Czech word “memory.” I chose it because it contains two characters that Erlang considers “unprintable.”) IIRC Erlang, which originated in Sweden, suggests that if the character does not exist in Latin 1, this non-printable. Therefore, despite the fact that I run the shell on a modern Linux field, where it is all UTF-8, it displays a list of integers instead of "Paměť".

My question is: how do I write a UTF-8 string to the screen so that it displays as a string of characters and not a list of integers?

+5
source share
1 answer

, : http://www.erlang.org/doc/apps/stdlib/unicode_usage.html

, , - :

1> lists:keyfind(encoding, 1, io:getopts()).
{encoding, unicode}
2> io:format("~ts~n",["Paměť"]).
Paměť
ok
3> 
+12

All Articles