简体   繁体   中英

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.

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
          ^^^^

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM