un-inception/test/qr.cr
russell@unturf.com bd91337584 fix(qr): Crystal use C FFI instead of qr-code shard
Crystal shards pre-cached during build aren't available for
single-file execution. Use @[Link("qrencode")] FFI instead.
2026-01-28 07:59:57 -05:00

19 lines
494 B
Crystal

@[Link("qrencode")]
lib LibQRencode
struct QRcode
version : LibC::Int
width : LibC::Int
data : UInt8*
end
fun QRcode_encodeString(s : LibC::Char*, version : LibC::Int, level : LibC::Int, hint : LibC::Int, casesensitive : LibC::Int) : QRcode*
fun QRcode_free(qr : QRcode*)
end
qr = LibQRencode.QRcode_encodeString("unsandbox-qr-ok", 0, 1, 2, 1)
if qr.null?
puts "QR encode failed"
exit 1
end
puts "QR:unsandbox-qr-ok:ROWS:#{qr.value.width}"
LibQRencode.QRcode_free(qr)