diff --git a/Project.toml b/Project.toml index 5b19378..db6f57a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "QRCoders" uuid = "f42e9828-16f3-11ed-2883-9126170b272d" authors = ["Jérémie Gillet and contributors"] -version = "1.2.0" +version = "1.2.1" [deps] FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" diff --git a/docs/src/index.md b/docs/src/index.md index 1ee759c..3668f24 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -7,18 +7,27 @@ Module that can create QR codes as data or images using `qrcode` or `exportqrcod ```@docs qrcode exportqrcode -getversion -getmode +``` + +## styled QR codes + +Plot in REPL. + +```@docs +unicodeplot +unicodeplotbychar ``` ## Encoding modes -There are three several encoding mode currently supported. +There are five several encoding mode currently supported. ```@docs Mode Numeric Alphanumeric Byte +Kanji +UTF8 ``` ## Error Correction diff --git a/src/errorcorrection.jl b/src/errorcorrection.jl index 6ce4964..d798f69 100644 --- a/src/errorcorrection.jl +++ b/src/errorcorrection.jl @@ -31,11 +31,9 @@ end """ Values of log₂1, log₂2, ..., log₂255 in GF(256). - -It is a table of `Int` instead of `UInt8` to avoid integers overflow. """ const antipowtable = let - table = Vector{Int}(undef, 255) + table = Vector{UInt8}(undef, 255) table[powtable] .= 0:254 table end @@ -59,18 +57,17 @@ gflog2(n::Integer) = antipowtable[n] """ gfinv(a::Integer) """ -gfinv(a::Integer) = gfpow2(-gflog2(a)) +gfinv(a::Integer) = gfpow2(0xff-gflog2(a)) """ Multiplication table of non-zero elements in GF(256). """ -const multtable = [iszero(i * j) ? 0x0 : gfpow2(gflog2(i) + gflog2(j)) for i in 0:255, j in 0:255] - +const multtable = [iszero(i * j) ? 0x0 : gfpow2(Int(gflog2(i)) + gflog2(j)) for i in 0:255, j in 0:255] """ Division table of non-zero elements in GF(256). """ -const divtable = [iszero(i) ? 0x0 : gfpow2(gflog2(i) - gflog2(j)) for i in 0:255, j in 1:255] +const divtable = [iszero(i) ? 0x0 : gfpow2(Int(gflog2(i)) - gflog2(j)) for i in 0:255, j in 1:255] """ mult(a::Integer, b::Integer) @@ -176,8 +173,8 @@ Increase the degree of `p` by `n`. <<(p::Poly{T}, n::Int) where T = Poly{T}(vcat(zeros(T, n), p.coeff)) function +(a::Poly{T}, b::Poly{T}) where T - l = max(length(a), length(b)) - return Poly{T}([xor(get(a.coeff, i, zero(T)), get(b.coeff, i, zero(T))) for i in 1:l]) + l, o = max(length(a), length(b)), zero(T) + return Poly{T}([xor(get(a.coeff, i, o), get(b.coeff, i, o)) for i in 1:l]) end """ @@ -185,8 +182,8 @@ end Multiply two polynomials or a polynomial with a scalar. """ -*(a::T, p::Poly{T}) where T = Poly{T}(mult.(a, p.coeff)) -*(p::Poly{T}, a::T) where T = Poly{T}(mult.(a, p.coeff)) +*(a::Integer, p::Poly{T}) where T = Poly{T}(mult.(a, p.coeff)) +*(p::Poly{T}, a::Integer) where T = Poly{T}(mult.(a, p.coeff)) function *(a::Poly{T}, b::Poly{T}) where T prodpoly = Poly(zeros(T, length(a) + length(b) - 1)) for (i, c1) in enumerate(a.coeff), (j, c2) in enumerate(b.coeff)