Skip to content

Commit 0408ab8

Browse files
committed
Issue #2 - provisional resolution to RFC3339 date encoding
Fixes an issue where a GF(256) remainder used for reed-solomon error correction bytes is a codeword short on return from division. This may not be the final resolution to the wider issue.
1 parent b272cb7 commit 0408ab8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/qrcode_reedsolomon.erl

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ encode(Bin, Degree) when Degree > 0 ->
2525
Data = binary_to_list(Bin),
2626
Coeffs = gf256:monomial_product(Field, Data, 1, Degree),
2727
{_Quotient, Remainder} = gf256:divide(Field, Coeffs, Generator),
28-
ErrorCorrectionBytes = list_to_binary(Remainder),
28+
Remainder0 = zero_pad(Degree, Remainder),
29+
ErrorCorrectionBytes = list_to_binary(Remainder0),
2930
<<ErrorCorrectionBytes/binary>>.
3031

32+
zero_pad(Length, R) when length(R) < Length ->
33+
zero_pad(Length, [0|R]);
34+
zero_pad(_, R) ->
35+
R.
3136
%%
3237
bch_code(Byte, Poly) ->
3338
MSB = msb(Poly),

0 commit comments

Comments
 (0)