From 2a8c7df6c76ed7c262fc5cbad5e1aa0eda9ae68f Mon Sep 17 00:00:00 2001 From: Simon Skorokhodov <skorohodovsemen@gmail.com> Date: Tue, 6 Mar 2018 21:49:40 +0100 Subject: [PATCH] Add description of `utf8_binary` type to README --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dd5f5b6..553e7a0 100644 --- a/README.md +++ b/README.md @@ -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: ```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(). @@ -244,7 +244,8 @@ A long option can have the following syntax: 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 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 +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 ------------------ -- 2.19.0