aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2013-07-29 15:59:35 +0200
committerAnders Svensson <[email protected]>2013-07-30 17:58:33 +0200
commitff4f753dbf02693c288d7e15cb3486359e73831f (patch)
treef3dad37691005a1bbebddf698f843ee73ae0a5cd /lib
parent8f69052ae8c27115f0cd1756e6949139759aa751 (diff)
downloadotp-ff4f753dbf02693c288d7e15cb3486359e73831f.tar.gz
otp-ff4f753dbf02693c288d7e15cb3486359e73831f.tar.bz2
otp-ff4f753dbf02693c288d7e15cb3486359e73831f.zip
Use module unicode for UTF8String encode/decode
The original code predates that module but there's no reason not to use it now.
Diffstat (limited to 'lib')
-rw-r--r--lib/diameter/src/base/diameter_types.erl27
1 files changed, 2 insertions, 25 deletions
diff --git a/lib/diameter/src/base/diameter_types.erl b/lib/diameter/src/base/diameter_types.erl
index ab7a7f3549..7ebf891819 100644
--- a/lib/diameter/src/base/diameter_types.erl
+++ b/lib/diameter/src/base/diameter_types.erl
@@ -354,36 +354,13 @@ v6enc([], B) ->
%% --------------------
'UTF8String'(decode, Bin) ->
- udec(Bin, []);
+ tl([0|_] = unicode:characters_to_list([0, Bin])); %% assert list return
'UTF8String'(encode = M, zero) ->
'UTF8String'(M, []);
'UTF8String'(encode, S) ->
- uenc(if is_binary(S) -> [S]; true -> S end, []).
-
-udec(<<>>, Acc) ->
- lists:reverse(Acc);
-
-udec(<<C/utf8, Rest/binary>>, Acc) ->
- udec(Rest, [C | Acc]).
-
-uenc([], Acc) ->
- list_to_binary(lists:reverse(Acc));
-
-uenc([E | Rest], Acc)
- when E == <<>>;
- E == [] ->
- uenc(Rest, Acc);
-
-uenc([[H|T] | Rest], Acc) ->
- uenc([H, T | Rest], Acc);
-
-uenc([<<C/utf8, T/binary>> | Rest], Acc) ->
- uenc([C, T | Rest], Acc);
-
-uenc([C | Rest], Acc) ->
- uenc(Rest, [<<C/utf8>> | Acc]).
+ <<_/binary>> = unicode:characters_to_binary(S). %% assert binary return
%% --------------------