Skip to content

Commit f86fe36

Browse files
committed
[stdlib] Fix unicode:characters_to_binary/3
1 parent f483994 commit f86fe36

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

lib/stdlib/src/unicode.erl

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,12 @@ characters_to_binary_int(ML, InEncoding, OutEncoding) ->
445445
{error, Accum, [Part]}
446446
end,<<>>),
447447
case Res of
448+
Bin when is_binary(Bin) ->
449+
Bin;
448450
{incomplete,A,B,_} ->
449451
{incomplete,A,B};
450-
_ ->
451-
Res
452+
{error, _Converted, _Rest} = Error ->
453+
Error
452454
end.
453455

454456

@@ -528,14 +530,7 @@ ml_map([Part|_] = Whole,_,{{Incomplete, _}, Accum}) when is_integer(Part) ->
528530
ml_map([Part|T],Fun,Accum) when is_integer(Part) ->
529531
case Fun(Part,Accum) of
530532
Bin when is_binary(Bin) ->
531-
case ml_map(T,Fun,Bin) of
532-
Bin2 when is_binary(Bin2) ->
533-
Bin2;
534-
{error, Converted, Rest} ->
535-
{error, Converted, Rest};
536-
{incomplete, Converted, Rest,X} ->
537-
{incomplete, Converted, Rest,X}
538-
end;
533+
ml_map(T,Fun,Bin);
539534
% Can not be incomplete - it's an integer
540535
{error, Converted, Rest} ->
541536
{error, Converted, [Rest|T]}

0 commit comments

Comments
 (0)