[erlang-questions] source file encoding

Justus mapandfold@REDACTED
Mon Dec 19 11:18:07 CET 2011


Hi all,

Strings must be in the ISO-latin-1 character set. I remember that
errors will be reported if other characters occurring in a .erl file
when compiling.

But when trying R15B, it looks that values beyond ISO-latin-1 are also
accepted. So now, we can use UTF8 without BOM encoding, and with the
help of ct_expand, I managed to say "hello world" in Chinese
literally.

I wonder is there any plan add Unicode support in string- and
character-literals?

-compile({parse_transform, ct_expand}).

-define(STR(S), ct_expand:term(unicode:characters_to_list(list_to_binary(S)))).

hello_world() ->
    S = ?STR("你好, 世界"),
    io:format("~ts~n", [S]).

-- 
Best Regards,
Justus



More information about the erlang-questions mailing list