mirror of
https://github.com/correl/urilib.git
synced 2024-11-24 11:09:59 +00:00
Shrink up the hex_to_upper method
This commit is contained in:
parent
2850835414
commit
bcc245b2a9
1 changed files with 17 additions and 13 deletions
|
@ -321,16 +321,20 @@ url_maybe_add_fragment(Value, URL) ->
|
||||||
-spec hex_to_upper(string()) -> string().
|
-spec hex_to_upper(string()) -> string().
|
||||||
%% @private
|
%% @private
|
||||||
hex_to_upper(Value) ->
|
hex_to_upper(Value) ->
|
||||||
hex_to_upper(Value, [], []).
|
hex_to_upper(Value, []).
|
||||||
hex_to_upper([], [], Value) ->
|
hex_to_upper([], Accum) ->
|
||||||
Value;
|
Accum;
|
||||||
hex_to_upper([], Hex, Value) ->
|
hex_to_upper([$%, B1, B2|T], Accum) ->
|
||||||
lists:append(Value, string:to_upper(Hex));
|
hex_to_upper(T, lists:append(Accum, [$%, to_upper(B1), to_upper(B2)]));
|
||||||
hex_to_upper([37|T], [], Value) ->
|
hex_to_upper([H|T], Accum) ->
|
||||||
hex_to_upper(T, [37], Value);
|
hex_to_upper(T, lists:append(Accum, [H])).
|
||||||
hex_to_upper([H|T], [], Value) ->
|
|
||||||
hex_to_upper(T, [], lists:append(Value, [H]));
|
|
||||||
hex_to_upper(Remaining, Hex, Value) when length(Hex) == 3 ->
|
-spec to_upper(char()) -> char().
|
||||||
hex_to_upper(Remaining, [], lists:append(Value, string:to_upper(Hex)));
|
to_upper($a) -> $A;
|
||||||
hex_to_upper([H|T], Hex, Value) ->
|
to_upper($b) -> $B;
|
||||||
hex_to_upper(T, lists:append(Hex, [H]), Value).
|
to_upper($c) -> $C;
|
||||||
|
to_upper($d) -> $D;
|
||||||
|
to_upper($e) -> $E;
|
||||||
|
to_upper($f) -> $F;
|
||||||
|
to_upper(C) -> C.
|
||||||
|
|
Loading…
Reference in a new issue