Matt
Matt

Reputation: 88067

What file encoding does Elixir expect?

When Elixir reads a source file to compile it, what encoding does it expect the file to be in? I want to include some literal strings with higher unicode values.

Upvotes: 2

Views: 283

Answers (1)

Dogbert
Dogbert

Reputation: 222188

UTF-8.

From http://elixir-lang.github.io/crash-course.html:

Elixir also expects your source files to be UTF-8 encoded.

We can also experimentally verify this. π in UTF-8 is 0xCF 0x80

$ cat a.exs
IO.puts "π"
$ xxd a.exs
00000000: 494f 2e70 7574 7320 22cf 8022 0a         IO.puts "..".
                                ^^ ^^
$ elixir a.exs
π
$ elixir a.exs | xxd
00000000: cf80 0a
          ^^^^

Upvotes: 8

Related Questions