Hi, <br><br>I found that erl and escript behaved differently when the string module was used for unicode strings. <br><br>Attached are what I tried to run with erl and escript. I also copied the code at the bottom of this e-mail.<br>
<br>When I did<br><br>%> escript test.erl<br><br>This works fine. <br><br>However, when I used erl to run it, I got an error as follows. <br><br>------------------<br>%> erlc test.erl<br>%> erl -noshell -s test main -s init stop<br>
{"init terminating in do_boot",{undef,[{test,main,[]},{init,start_it,1},{init,start_em,1}]}}<br><br>Crash dump was written to: erl_crash.dump<br>init terminating in do_boot ()<br>-----------------<br><br>After looking into this for a while, I start thinking that it seems that this occurs when I use string:tokens (Or some function in the string module. I have not tried other functions in the string module yet.)<br>
<br>I am wondering what difference between erl and escript causes this.  <br>Is there anyone who have had a similar thing?<br><br>Chiharu<br><br><br>------------------------<br><br>-module(test).<br><br>-compile(export_all).<br>
<br>for_each_line(Filename, [_, {encoding, Encoding}]=Mode, F, Args) -><br>    io:setopts([{encoding, Encoding}]),    <br>    case file:open(Filename, Mode) of<br>        {ok, Device} -><br>            F(Device, Encoding, Args);<br>
        {error, Reason} -><br>            erlang:error(Reason)<br>    end.<br><br>tokens(Device, Encoding, N) -><br>    case io:get_line(Device, "") of<br>        {error, Reason} -><br>            erlang:error(Reason),<br>
            file:close(Device);<br>        eof -><br>            file:close(Device);<br>        Line -><br>            Tokens = string:tokens(Line, " "),<br>            lists:foreach(<br>              fun(T) -> io:format("~ts~n", [T]) end,<br>
              Tokens<br>             ),<br>            tokens(Device, Encoding, N)<br>    end.<br><br>main(_) -><br>    for_each_line("test1.txt", [read, {encoding, utf8}], fun test:tokens/3, 1).<br><br><br><br>