From cb26dafd15aaa460e2d477947e95e13687464256 Mon Sep 17 00:00:00 2001 From: Craig Everett Date: Thu, 8 Jan 2026 16:10:15 +0900 Subject: [PATCH] WIP --- src/hz.erl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/hz.erl b/src/hz.erl index 2d909e1..bb4195b 100644 --- a/src/hz.erl +++ b/src/hz.erl @@ -1943,6 +1943,8 @@ coerce({O, N, char}, Str, to_fate) -> _ -> single_error({invalid, O, N, Str}) end; +coerce({O, N, {bytes, [Count]}}, Bytes, to_fate) when is_list(Bytes) -> + coerce_bytes(O, N, Count, convert_bytes(Bytes)); coerce({O, N, {bytes, [Count]}}, Bytes, _Direction) when is_bitstring(Bytes) -> coerce_bytes(O, N, Count, Bytes); coerce({_, _, bits}, {bits, Num}, from_fate) -> @@ -2011,6 +2013,13 @@ coerce_bytes(O, N, Count, Bytes) when byte_size(Bytes) /= Count -> coerce_bytes(_, _, _, Bytes) -> {ok, Bytes}. +convert_bytes([$# | Rest]) -> + convert_bytes(Rest, <<>>). + +convert_bytes([A, B | T], J) -> convert_bytes(T, <>); +convert_bytes([], J) -> {ok, J}; +convert_bytes(O, J) -> {error, {J, O}}. + coerce_chain_object(_, _, _, _, {raw, Binary}) -> {ok, Binary}; coerce_chain_object(O, N, T, Tag, S) ->