<div dir="ltr"><div><div><div><div><div>Hi - this is very probably related to the problem (and cause) described in this thread:<br>  <a href="http://erlang.org/pipermail/erlang-bugs/2012-January/002747.html">http://erlang.org/pipermail/erlang-bugs/2012-January/002747.html</a><br>
</div>A simpler demo is:<br><br>  $ erl -eval 'io:format("[~ts]\n", [[300]]), timer:sleep(2000), init:stop().' <br>  Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] [systemtap]<br>
  <br>  Eshell V5.9.1  (abort with ^G)<br>  1> [Ĭ]<br><br>versus<br><br>  $ erl -noinput -eval 'io:format("[~ts]\n", [[300]]), timer:sleep(2000), init:stop().' <br>  [\x{12C}]<br><br></div>and the cause is, briefly put, that the code handling output is different in the two cases.<br>
<br></div>The solution, equally briefly, is to set the encoding manually in the escript:<br><br>  $ erl -noinput -eval 'ok = io:setopts([{encoding, unicode}]), io:format("[~ts]\n", [[300]]), timer:sleep(2000), init:stop().' <br>
  [Ĭ]<br><br><br></div>(That is, I've not tested it with escript, but I'd be surprised if it didn't work :-))<br><br></div>/Erik<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-10 6:13 GMT+01:00 John Daily <span dir="ltr"><<a href="mailto:jd@epep.us" target="_blank">jd@epep.us</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">I retract my retraction. Setting aside the unworkable Farsi2 variable, Farsi (expressed in bytes) really should work, but displays as \x{641}\x{627}\x{631}\x{633}\x{6CC}. Why?<span class="HOEnZb"><font color="#888888"><div>
<br></div><div>-John</div></font></span><div><div class="h5"><div><br><div><div>On Mar 10, 2014, at 12:34 AM, John Daily <<a href="mailto:jd@epep.us" target="_blank">jd@epep.us</a>> wrote:</div><br><blockquote type="cite">
<div style="word-wrap:break-word">And I think I’ve found the solution in an older thread. Still no support for unicode strings directly embedded in the source. Thanks, sorry for the noise.<div><br></div><div>-John</div><div>
<br><div><div>On Mar 10, 2014, at 12:24 AM, John Daily <<a href="mailto:jd@epep.us" target="_blank">jd@epep.us</a>> wrote:</div><br><blockquote type="cite"><div style="word-wrap:break-word"><span style="font-size:15px">I ran into a problem with io:format() when invoked remotely, and with Scott Fritchie’s assistance I’ve narrowed it down (I think) to escript.</span><div style="font-size:15px">
<br></div><div style="font-size:15px">Here’s my script:</div><div style="font-size:15px"><br></div><div style="font-size:15px"><div><font face="Andale Mono">#!/usr/bin/env escript</font></div><div><font face="Andale Mono">%%</font></div>
<div><font face="Andale Mono">%%! -sname foo</font></div><div><font face="Andale Mono"><br></font></div><div><font face="Andale Mono">main([]) -></font></div><div><font face="Andale Mono">   Other = 'bar@localhost',</font></div>
<div><font face="Andale Mono">   Farsi = [1601,1575,1585,1587,1740],</font></div><div><font face="Andale Mono">   Farsi2 = "فارسی",</font></div><div><font face="Andale Mono">   spawn(Other, fun() -> io:format("Bytes: ~ts~n", [Farsi]) end),</font></div>
<div><font face="Andale Mono">   spawn(Other, fun() -> io:format("Bytes: ~w~n", [Farsi]) end),</font></div><div><font face="Andale Mono">   spawn(Other, fun() -> io:format("Paste: ~ts~n", [Farsi2]) end),</font></div>
<div><font face="Andale Mono">   spawn(Other, fun() -> io:format("Paste: ~w~n", [Farsi2]) end),</font></div><div><font face="Andale Mono">   timer:sleep(1000).</font></div></div><div style="font-size:15px"><br>
</div><div style="font-size:15px">When attempting this directly from a different node’s console (spawned to run on ‘bar’), everything displays as expected:</div><div style="font-size:15px"><br></div><div style="font-size:15px">
<div><font face="Andale Mono">Bytes: فارسی</font></div><div><font face="Andale Mono">Bytes: [1601,1575,1585,1587,1740]</font></div><div><font face="Andale Mono">Paste: فارسی</font></div><div><font face="Andale Mono">Paste: [1601,1575,1585,1587,1740]</font></div>
</div><div style="font-size:15px"><br></div><div style="font-size:15px">When invoked via the above escript, I consistently get the wrong output:</div><div style="font-size:15px"><br></div><div style="font-size:15px"><div>
<font face="Andale Mono">Bytes: \x{641}\x{627}\x{631}\x{633}\x{6CC}</font></div><div><font face="Andale Mono">Bytes: [1601,1575,1585,1587,1740]</font></div><div><font face="Andale Mono">Paste: فارسی</font></div><div><font face="Andale Mono">Paste: [217,129,216,167,216,177,216,179,219,140]</font></div>
</div><div style="font-size:15px"><br></div><div style="font-size:15px">This is repeatable on R15B01 and R16B03-1, both under OS X Mavericks installed via kerl. My LANG environment variable is set to en_US.UTF-8, and all other UTF-8 behavior seems correct.</div>
<div style="font-size:15px"><br></div><div style="font-size:15px">Just spun up an older Amazon Linux AMI instance running R15B01. Same behavior.</div><div style="font-size:15px"><br></div><div style="font-size:15px">My unicode experience consists of years of banging my head against various toolchain problems with only a marginal clue as to what’s supposed to happen, so my ability to troubleshoot this further is limited.</div>
<div style="font-size:15px"><br></div><div style="font-size:15px">-John</div><div><br></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div></div></div><br>_______________________________________________<br>

erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>