Add description of utf8_binary type to README

This commit is contained in:
Simon Skorokhodov 2018-03-06 21:49:40 +01:00
parent b3e4a77172
commit 2a8c7df6c7

View File

@ -57,7 +57,7 @@ The `parse/2` function receives a list of tuples with the command line option
specifications. The type specification for the tuple is: specifications. The type specification for the tuple is:
```erlang ```erlang
-type arg_type() :: 'atom' | 'binary' | 'boolean' | 'float' | 'integer' | 'string'. -type arg_type() :: 'atom' | 'binary' | 'utf8_binary' | 'boolean' | 'float' | 'integer' | 'string'.
-type arg_value() :: atom() | binary() | boolean() | float() | integer() | string(). -type arg_value() :: atom() | binary() | boolean() | float() | integer() | string().
@ -244,7 +244,8 @@ A long option can have the following syntax:
Argument Types Argument Types
-------------- --------------
The arguments allowed for options are: *atom*; *binary*; *boolean*; *float*; *integer*; *string*. The arguments allowed for options are: *atom*; *binary*; *utf8_binary*; *boolean*;
*float*; *integer*; *string*.
The `getopt` module checks every argument to see if it can be converted to its The `getopt` module checks every argument to see if it can be converted to its
correct type. correct type.
@ -256,6 +257,17 @@ Numeric arguments can only be negative when passed as part of an assignment expr
e.g. `--increment=-100` is a valid expression; whereas `--increment -100` is invalid e.g. `--increment=-100` is a valid expression; whereas `--increment -100` is invalid
Arguments of `utf8_binary` type allow proper binary encoding of arguments containing
code points greater than 255. The resulting value is a normalized UTF-8 binary.
As of Erlang/20, `standart_error` device has `unicode` option set to `false`.
It prevents correct printing of usage for arguments containing unicode
binaries/strings as default values. To fix this, one needs to enable unicode:
```erlang
io:setopts(standard_error, [{unicode, true}]).
```
Implicit Arguments Implicit Arguments
------------------ ------------------