[erlang-questions] escript argument encoding
Siri Hansen
erlangsiri@REDACTED
Fri Mar 21 17:29:18 CET 2014
It is mentioned here:
http://www.erlang.org/doc/apps/stdlib/unicode_usage.html#id62041, but there
might be other places where it should be added. A user contribution will of
course make such an improvement happen faster!
/siri
fredagen den 21:e mars 2014 skrev Vlad Dumitrescu <vladdu55@REDACTED>:
> It's not obvious to me that arguments on the command line of a script are
> handled as file names. Shouldn't there be a notice on the relevant doc page?
>
> Regards,
> Vlad
> On 20 Mar 2014 19:42, "José Valim" <jose.valim@REDACTED<javascript:_e(%7B%7D,'cvml','jose.valim@REDACTED');>>
> wrote:
>
>> Take a look at the +fnu flags:
>>
>> http://erlang.org/doc/man/erl.html
>>
>>
>>
>> *José Valim*
>> www.plataformatec.com.br
>> Skype: jv.ptec
>> Founder and Lead Developer
>>
>>
>> On Thu, Mar 20, 2014 at 7:38 PM, Reid Draper <reiddraper@REDACTED<javascript:_e(%7B%7D,'cvml','reiddraper@REDACTED');>
>> > wrote:
>>
>>> I’m running into an issue where OSX and Linux seem to treat the
>>> command-line arguments to an escript differently. Using the following
>>> escript:
>>>
>>> #!/usr/bin/env escript
>>> %% -*- erlang -*-
>>> %%! +pc unicode
>>>
>>> main([Args]) ->
>>> io:setopts([{encoding, utf8}]),
>>> io:format("~w~n", [Args]),
>>> io:format("~ts~n", [Args]).
>>>
>>> Both my OSX and Linux (Ubuntu 13.10) boxes have their LANG set
>>> to en_US.UTF-8. I’m running the escript like so:
>>>
>>> ./sample.escript سلام
>>>
>>> On OSX, the escript seems to treat `Args` as a list of unicode
>>> code-points:
>>>
>>> ./sample.escript سلام
>>> [1587,1604,1575,1605]
>>> سلام
>>>
>>> On Linux, it seems to treat the input as a list of UTF-8 bytes, where
>>> each byte is turned into an integer. The Erlang unicode guide calls this a
>>> 'Lists of UTF-8 Bytes' [1].
>>>
>>> ./sample.escript سلام
>>> [216,179,217,132,216,167,217,133]
>>> سلام
>>>
>>> How does I get both OSX and Linux to treat the input of the escript as a
>>> list of code-points?
>>>
>>> Thanks,
>>> Reid
>>>
>>> [1] http://www.erlang.org/doc/apps/stdlib/unicode_usage.html
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED<javascript:_e(%7B%7D,'cvml','erlang-questions@REDACTED');>
>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>
>>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED<javascript:_e(%7B%7D,'cvml','erlang-questions@REDACTED');>
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140321/8da400a8/attachment.htm>
More information about the erlang-questions
mailing list