Quarer 0.2.1-preview2
See the version list below for details.
dotnet add package Quarer --version 0.2.1-preview2
NuGet\Install-Package Quarer -Version 0.2.1-preview2
<PackageReference Include="Quarer" Version="0.2.1-preview2" />
paket add Quarer --version 0.2.1-preview2
#r "nuget: Quarer, 0.2.1-preview2"
// Install Quarer as a Cake Addin #addin nuget:?package=Quarer&version=0.2.1-preview2&prerelease // Install Quarer as a Cake Tool #tool nuget:?package=Quarer&version=0.2.1-preview2&prerelease
Quarer
A fast and simple-to-use QR code encoding library.
By vectorizing many parts of the QR Code creation process, Quarer manages to be much faster than many other libraries. Quarer supports ECI mode encoding as well as Kanji.
See the full results. Want to add get your library added to the benchmarks? Open an issue!
Installation
dotnet add package Quarer
Usage
Create a QR Code
using Quarer;
var qrCode = QrCode.Create("Hello, World!");
Console.WriteLine(qrCode.Version);
Console.WriteLine(qrCode.Width);
Console.WriteLine(qrCode.ErrorCorrectionLevel);
Output the QR code using a tool of your choice. The example below outputs directly to the console:
Console.WriteLine("Encoding \"Hello, World!\"");
var qrCode = QrCode.Create("Hello, World");
var sb = new StringBuilder();
OutputYPadding(sb, qrCode.Width);
for (var y = 0; y < qrCode.Height; y++)
{
for (var x = -4; x < qrCode.Width + 4; x++)
{
if (x < 0 || x >= qrCode.Width)
{
sb.Append("██");
continue;
}
var v = qrCode.Data[x, y] != 0;
var s = v ? " " : "██";
sb.Append(s);
}
sb.AppendLine();
}
OutputYPadding(sb, qrCode.Width);
Console.WriteLine(sb.ToString());
static void OutputYPadding(StringBuilder sb, int width)
{
for (var y = 0; y < 4; y++)
{
for (var x = 0; x < width + 8; x++)
{
sb.Append('█');
sb.Append('█');
}
sb.AppendLine();
}
}
See more samples.
Features
Automatic Latin1 detection
Byte-mode encoding for a QR Code defaults to Latin1. Quarer detects when it could be beneficial to transcode a string to Latin1, otherwise, Quarer defaults to UTF-8. Latin1 is a more compact encoding than UTF-8 for some characters. In addition, Quarer can also skip emitting the ECI indicator for such a case.
For example:
var s = "Ã";
Console.WriteLine(Encoding.UTF8.GetBytes(s).Length); // 2
Console.WriteLine(Encoding.Latin1.GetBytes(s).Length); // 1
Encode at a specific error correction level
var qrCode = QrCode.Create("Hello, World!", ErrorCorrectionLevel.H);
Encode using a specific version
var qrCode = QrCode.Create("Hello, World!", QrVersion.GetVersion(5), ErrorCorrectionLevel.M);
Encode binary data
var qrCode = QrCode.Create([0xFE, 0xED, 0xCA, 0xFE]);
ECI support
// 26 is the ECI code for UTF-8
var eciCode = new EciCode(26);
var data = Encoding.UTF8.GetBytes("Hello, World!");
var qrCode = QrCode.Create(data, ErrorCorrectionLevel.M, eciCode);
Roadmap
- Micro QR Codes
- rMQR Codes
- QR code Decoding
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.2.1 | 82 | 10/25/2024 |
0.2.1-preview2 | 82 | 10/25/2024 |
0.2.1-preview1 | 68 | 10/25/2024 |