[erlang-questions] utf8 in source files

Thomas Lachmann <>
Mon Nov 8 23:37:17 CET 2010


Hi.

Am Mon, 08 Nov 2010 21:58:22 +0100
schrieb Allan Wegan <>:

> Just let them use UTF-8 at will. As long as they do not use any
> non-ASCII code points in language constructs except binary string
> literals, they should be on the safe side anyway.

May be I'm wrong in my understanding of binary string literal is wrong.
But using non-ASCII letters in binaries has been the place where I
first realized, that I did store my erlang source code in utf-8 instead
of latin-1.

The following code does print "Size: 6" if encoded in latin-1 and "Size:
12" if encoded in utf-8.

-module(src_enc).

-compile([export_all]).

t()->
    B = <<"üüüüüü">>,
    io:format("Size: ~w~n", [byte_size(B)]).

best regards,
Thomas


More information about the erlang-questions mailing list