komone / qrcode Goto Github PK
View Code? Open in Web Editor NEWQR Code encoder in Erlang
License: Other
QR Code encoder in Erlang
License: Other
Hello,
I'm encoding the following string into the QR: http://localhost:4000/v1/sessions/9a454d3bb5d14369842f21a8f9683a87
which results in this image:
The problem is that the actual data embedded in the QR is: http://localhost:4000/v1/sessions/9a454d3bb5d14369842f21a8f9683a8'
. Notice the 7
at the end turned into '
. I also saw similar errors which had 1 character wrong but not at the end of the string.
Here's my erl -v
erl -v
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
One thing to note is that when using Q
or L
error correction modes it is working fine, at least for the given input string.
qrcode:encode(<<"12345678901234">>).
is crashing, I am trying to fix it. Any help to fix it the "right" way would be helpful.
I guess other sizes may crash as well.
If I switch code encode(Bin, 'M').
to encode(Bin, 'H').
in qrcode.erl
.
I get this:
** (exit) an exception was raised:
** (FunctionClauseError) no function clause matching in :qrcode_matrix.encode_bits0/2
(qrcode) src/qrcode_matrix.erl:169: :qrcode_matrix.encode_bits0([:d, :d, :d, :d, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1], <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 0::size(1)>>)
(qrcode) src/qrcode_matrix.erl:164: :qrcode_matrix.encode_bits/3
(qrcode) src/qrcode_matrix.erl:53: :qrcode_matrix.finalize/5
(qrcode) src/qrcode.erl:43: :qrcode.encode/2
(qrcode) src/qrcode_png.erl:50: :qrcode_png.run/1
(shoqr) web/controllers/v1/session_controller.ex:46: Shoqr.V1.SessionController.show_qr/2
(shoqr) web/controllers/v1/session_controller.ex:11: Shoqr.V1.SessionController.phoenix_controller_pipeline/2
(shoqr) lib/phoenix/router.ex:265: Shoqr.Router.dispatch/2
(shoqr) web/router.ex:11: Shoqr.Router.do_call/2
(shoqr) lib/shoqr/endpoint.ex:11: Shoqr.Endpoint.phoenix_pipeline/1
(shoqr) lib/plug/debugger.ex:90: Shoqr.Endpoint."call (overridable 3)"/2
(shoqr) lib/phoenix/endpoint/render_errors.ex:34: Shoqr.Endpoint.call/2
(plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
(cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
Note that switching to L
or Q
works fine.
Problem: Adding current commit to rebar.config and doing rebar compile gives:
...
ERROR: One or more modules listed in qrcode.app are not present in ebin/*.beam:
* reedsolomon
Solution: Changed "reedsolomon" to "qrcode_reedsolomon" in modules entry of ebin/qrcode.app.
An other crash I am also trying to fix, may or may not be related to the size issue in issue 1.
qrcode:encode(<<"2014-01:09T23:21:46">>).
This call crash in an other way, the fix is not obvious for me. Any one?
Some binary strings generate exception of qrcode:encode in qrcode_matrix:encode_bits0
exception error: no function clause matching
qrcode_matrix:encode_bits0([d,d,1,0,0,0,0,1,1,1,1,0,1,0,0,
1,0,1,0,0,0,0,0,0,1,0,1,0|...],
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,254,76,29,191,
128,65,...>>)
first parameter is [d,d,1,1,0,1,1,0,0,0,0,1,0,1,1,0,1,0,0,0,1,1,1,0,0,1,0,1,1,1,1,1,1]
and H = d is not integer, it doesn't match neither encode_bits0([H|T], Acc) when is_integer(H)
nor encode_bits0([], Acc)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.