Skip to content

Commit d34bf8c

Browse files
Merge pull request #6529 from rickard-green/rickard/unicode-characters_to_binary/OTP-18351
[stdlib] Fix unicode:characters_to_binary/3
2 parents 52995fe + f86fe36 commit d34bf8c

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
@@ -444,10 +444,12 @@ characters_to_binary_int(ML, InEncoding, OutEncoding) ->
444444
{error, Accum, [Part]}
445445
end,<<>>),
446446
case Res of
447+
Bin when is_binary(Bin) ->
448+
Bin;
447449
{incomplete,A,B,_} ->
448450
{incomplete,A,B};
449-
_ ->
450-
Res
451+
{error, _Converted, _Rest} = Error ->
452+
Error
451453
end.
452454

453455

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

0 commit comments

Comments
 (0)