From 785cb2081ff2c84453506380c97aced147df2b73 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Tue, 11 Mar 2014 09:41:19 +0100 Subject: erts: Clarify escript's encoding of the I/O-server A note has been added that clarifies that the encoding of the I/O-server has to be set explicitly, irrespective of any encoding comment. --- erts/doc/src/escript.xml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/escript.xml b/erts/doc/src/escript.xml index d2b09d4515..1abbdb2180 100644 --- a/erts/doc/src/escript.xml +++ b/erts/doc/src/escript.xml @@ -4,7 +4,7 @@
- 20072013 + 20072014 Ericsson AB. All Rights Reserved. @@ -92,6 +92,18 @@ $ escript factorial 5 marker="stdlib:epp#encoding">encoding it can be located on the second line.

+

+ The encoding specified by the above mentioned comment + applies to the script itself. The encoding of the + I/O-server, however, has to be set explicitly like this: +io:setopts([{encoding, unicode}])

+

The default encoding of the I/O-server for standard_io + is latin1 + since the script runs in a non-interactive terminal + (see + Using Unicode in Erlang). +

+

On the third line (or second line depending on the presence of the Emacs directive), it is possible to give arguments to the emulator, such as

@@ -141,8 +153,9 @@ halt(1). -include_lib("kernel/include/file.hrl").

to include the record definitions for the records used by the file:read_link_info/1 function. You can also select - encoding here, but if there is a valid encoding comment on - the second line it takes precedence.

+ encoding by including a encoding comment here, but if there + is a valid encoding comment on the second line it takes + precedence.

The script will be checked for syntactic and semantic correctness before being run. If there are warnings (such as @@ -163,7 +176,7 @@ halt(1). If much of the execution takes place in interpreted code it may be worthwhile to compile it, even though the compilation itself will take a little while. It is also possible to supply - native instead of compile, this will compile the script + native instead of compile, this will compile the script using the native flag, again depending on the characteristics of the escript this could or could not be worth while.

@@ -239,7 +252,7 @@ factorial 5 = 120 can either be returned as a binary or written to file.

As an example of how the function can be used, we create an - interpreted escript which uses emu_args to set some emulator + interpreted escript which uses emu_args to set some emulator flag. In this case it happens to disable the smp_support. We do also extract the different sections from the newly created script:

-- cgit v1.2.3