<div><br></div><div><br></div>Hello all,<div><br></div><div>I'm investigating Unicode support in Erlang. And have found the difference in behaviour of erl shell and compile:file.</div><div><br></div><div>The erl shell:</div>
<div><br></div><div>1. We configure our terminal emulator to use UTF-8</div><div>2. We set io:setopts({encoding,unicode}).</div><div>3. Then in the prompt we enter a Unicode string and see the result -- a list of Unicode codepoints:</div>
<div><div>(emacs@AVINOKUROV)103> "АБВГД".</div><div>[1040,1041,1042,1043,1044]</div></div><div><br></div><div><br></div><div>The compile:file:</div><div><br></div><div>1. We save a file foo in UTF-8 with a function that return a Unicode string bar() -> "АБВГД".</div>
<div>2. Now we open an erl shell and run compile:file(foo).</div><div>3. Finally running foo:bar() we have a list of UTF-8 bytes.</div><div><div>(emacs@AVINOKUROV)111> foo:bar().</div><div>[208,144,208,145,208,146,208,147,208,148]</div>
</div><div><br></div><div><br></div><div>I dug the compile:file/1 and found epp:server/4 where the file is opened with file:open(Name, [read]) and where encoding of the returned IoDevice is not configured.</div><div><br></div>
<div>Why not to use one of the Unicode recipes from the Unicode usage doc (lib/stdlib-1.18/doc/html/unicode_usage.html) to set io:setopts(F,[{encoding,Type}]) or add an encoding option to the compile:file/2 and erlc?</div>
<div><br></div><div>What would be your suggestions, honorable all?</div><div><div><br></div>-- <br><div>Александр Винокуров</div><div>+7 (921) 982-21-43</div><div>@aleksandrvin</div><br>
</div>