In erlang, when defining a UTF-8 binary string, I need to specify the encoding in the binary literal, like this:
Star = <<"★"/utf8>>.
> <<226,152,133>>
io:format("~ts~n", [Star]).
> ★
> ok
But, if the /utf8
encoding is omitted, the unicode characters are not handled correctly:
Star1 = <<"★">>.
> <<5>>
io:format("~ts~n", [Star1]).
> ^E
> ok
Is there a way that I can create literal binary strings like this without having to specify /utf8
in every binary I create? My code has quite a few binaries like this and things have become quite cluttered. Is there a way to set some sort of default encoding for binaries?