Skip to content

Commit

Permalink
Accepting non latin1 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
GwendalLaurent committed May 6, 2024
1 parent d8d2144 commit 963dc97
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/grisp_tools_configure.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
% {Name, {Long, Short}, {Type, Default}, Description}
-type settings() :: {string(),
{string(), char()},
{string, string()} | {boolean, boolean()},
{string, string()}
| {boolean, boolean()}
| {latin1, string()},
string()}.

-type settings_options() :: {string(),
{string(), char()},
{string, string()} | {boolean, boolean()},
{string, string()}
| {boolean, boolean()}
| {latin1, string()},
string(),
function()} | settings().

Expand Down Expand Up @@ -109,7 +113,7 @@ settings() ->

-spec settings_options() -> [settings_options()].
settings_options() -> [
{"App name", {name, undefined}, {string, "robot"},
{"App name", {name, undefined}, {latin1, "robot"},
"The name of the OTP application"},
{"Erlang version", {otp_version, $o}, {string, "25"},
"The OTP version of the GRiSP app"},
Expand Down
11 changes: 10 additions & 1 deletion src/grisp_tools_io.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,21 @@ get(integer, String) ->
Integer ->
Integer
end;
get(latin1, []) ->
no_data;
get(latin1, Data) ->
case io_lib:latin1_char_list(Data) of
true ->
Data;
false ->
no_clue
end;
get(string, []) ->
no_data;
get(string, String) ->
case is_list(String) of
true ->
String;
unicode:characters_to_binary(String);
false ->
no_clue
end.
Expand Down

0 comments on commit 963dc97

Please sign in to comment.