• Home
Name Date Size #Lines LOC

..--

c/12-May-2024-2,8102,007

cpp/12-May-2024-1,703902

java/12-May-2024-2,2301,185

python/12-May-2024-1,234817

rust/12-May-2024-1,581897

typescript-javascript/12-May-2024-1,7141,084

BUILD.gnD12-May-20241.2 KiB5448

CMakeLists.txtD12-May-2024281 117

OAT.xmlD12-May-20241.1 KiB2912

README.OpenSourceD12-May-2024292 1211

Readme.markdownD12-May-20246.8 KiB210163

bundle.jsonD12-May-2024697 3131

README.OpenSource

1[
2  {
3    "Name": "QR-Code-generator",
4    "License": "MIT License",
5    "License File": "LICENSE",
6    "Version Number": " 1.7.0",
7    "Owner": "guorensong1@huawei.com",
8    "Upstream URL": "https://www.nayuki.io/page/qr-code-generator-library",
9    "Description": "QR-Code-generator"
10  }
11]
12

Readme.markdown

1QR Code generator library
2=========================
3
4
5Introduction
6------------
7
8This project aims to be the best, clearest QR Code generator library in multiple languages. The primary goals are flexible options and absolute correctness. Secondary goals are compact implementation size and good documentation comments.
9
10Home page with live JavaScript demo, extensive descriptions, and competitor comparisons: [https://www.nayuki.io/page/qr-code-generator-library](https://www.nayuki.io/page/qr-code-generator-library)
11
12
13Features
14--------
15
16Core features:
17
18* Available in 6 programming languages, all with nearly equal functionality: Java, TypeScript/JavaScript, Python, Rust, C++, C
19* Significantly shorter code but more documentation comments compared to competing libraries
20* Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard
21* Output format: Raw modules/pixels of the QR symbol
22* Detects finder-like penalty patterns more accurately than other implementations
23* Encodes numeric and special-alphanumeric text in less space than general text
24* Open source code under the permissive MIT License
25
26Manual parameters:
27
28* User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data
29* User can specify mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one
30* User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number
31* User can create a list of data segments manually and add ECI segments
32
33Optional advanced features (Java only):
34
35* Encodes Japanese Unicode text in kanji mode to save a lot of space compared to UTF-8 bytes
36* Computes optimal segment mode switching for text with mixed numeric/alphanumeric/general/kanji parts
37
38More information about QR Code technology and this library's design can be found on the project home page.
39
40
41Examples
42--------
43
44Java language:
45
46```java
47import java.awt.image.BufferedImage;
48import java.io.File;
49import java.util.List;
50import javax.imageio.ImageIO;
51import io.nayuki.qrcodegen.*;
52
53// Simple operation
54QrCode qr0 = QrCode.encodeText("Hello, world!", QrCode.Ecc.MEDIUM);
55BufferedImage img = toImage(qr0, 4, 10);  // See QrCodeGeneratorDemo
56ImageIO.write(img, "png", new File("qr-code.png"));
57
58// Manual operation
59List<QrSegment> segs = QrSegment.makeSegments("3141592653589793238462643383");
60QrCode qr1 = QrCode.encodeSegments(segs, QrCode.Ecc.HIGH, 5, 5, 2, false);
61for (int y = 0; y < qr1.size; y++) {
62    for (int x = 0; x < qr1.size; x++) {
63        (... paint qr1.getModule(x, y) ...)
64    }
65}
66```
67
68TypeScript/JavaScript languages:
69
70```typescript
71// Name abbreviated for the sake of these examples here
72const QRC = qrcodegen.QrCode;
73
74// Simple operation
75const qr0 = QRC.encodeText("Hello, world!", QRC.Ecc.MEDIUM);
76const svg = toSvgString(qr0, 4);  // See qrcodegen-input-demo
77
78// Manual operation
79const segs = qrcodegen.QrSegment.makeSegments("3141592653589793238462643383");
80const qr1 = QRC.encodeSegments(segs, QRC.Ecc.HIGH, 5, 5, 2, false);
81for (let y = 0; y < qr1.size; y++) {
82    for (let x = 0; x < qr1.size; x++) {
83        (... paint qr1.getModule(x, y) ...)
84    }
85}
86```
87
88Python language:
89
90```python
91from qrcodegen import *
92
93# Simple operation
94qr0 = QrCode.encode_text("Hello, world!", QrCode.Ecc.MEDIUM)
95svg = to_svg_str(qr0, 4)  # See qrcodegen-demo
96
97# Manual operation
98segs = QrSegment.make_segments("3141592653589793238462643383")
99qr1 = QrCode.encode_segments(segs, QrCode.Ecc.HIGH, 5, 5, 2, False)
100for y in range(qr1.get_size()):
101    for x in range(qr1.get_size()):
102        (... paint qr1.get_module(x, y) ...)
103```
104
105C++ language:
106
107```c++
108#include <string>
109#include <vector>
110#include "QrCode.hpp"
111using namespace qrcodegen;
112
113// Simple operation
114QrCode qr0 = QrCode::encodeText("Hello, world!", QrCode::Ecc::MEDIUM);
115std::string svg = toSvgString(qr0, 4);  // See QrCodeGeneratorDemo
116
117// Manual operation
118std::vector<QrSegment> segs =
119    QrSegment::makeSegments("3141592653589793238462643383");
120QrCode qr1 = QrCode::encodeSegments(
121    segs, QrCode::Ecc::HIGH, 5, 5, 2, false);
122for (int y = 0; y < qr1.getSize(); y++) {
123    for (int x = 0; x < qr1.getSize(); x++) {
124        (... paint qr1.getModule(x, y) ...)
125    }
126}
127```
128
129C language:
130
131```c
132#include <stdbool.h>
133#include <stdint.h>
134#include "qrcodegen.h"
135
136// Text data
137uint8_t qr0[qrcodegen_BUFFER_LEN_MAX];
138uint8_t tempBuffer[qrcodegen_BUFFER_LEN_MAX];
139bool ok = qrcodegen_encodeText("Hello, world!",
140    tempBuffer, qr0, qrcodegen_Ecc_MEDIUM,
141    qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX,
142    qrcodegen_Mask_AUTO, true);
143if (!ok)
144    return;
145
146int size = qrcodegen_getSize(qr0);
147for (int y = 0; y < size; y++) {
148    for (int x = 0; x < size; x++) {
149        (... paint qrcodegen_getModule(qr0, x, y) ...)
150    }
151}
152
153// Binary data
154uint8_t dataAndTemp[qrcodegen_BUFFER_LEN_FOR_VERSION(7)]
155    = {0xE3, 0x81, 0x82};
156uint8_t qr1[qrcodegen_BUFFER_LEN_FOR_VERSION(7)];
157ok = qrcodegen_encodeBinary(dataAndTemp, 3, qr1,
158    qrcodegen_Ecc_HIGH, 2, 7, qrcodegen_Mask_4, false);
159```
160
161Rust language:
162
163```rust
164extern crate qrcodegen;
165use qrcodegen::QrCode;
166use qrcodegen::QrCodeEcc;
167use qrcodegen::QrSegment;
168
169// Simple operation
170let qr = QrCode::encode_text("Hello, world!",
171    QrCodeEcc::Medium).unwrap();
172let svg = to_svg_string(&qr, 4);  // See qrcodegen-demo
173
174// Manual operation
175let chrs: Vec<char> = "3141592653589793238462643383".chars().collect();
176let segs = QrSegment::make_segments(&chrs);
177let qr = QrCode::encode_segments_advanced(
178    &segs, QrCodeEcc::High, 5, 5, Some(Mask::new(2)), false).unwrap();
179for y in 0 .. qr.size() {
180    for x in 0 .. qr.size() {
181        (... paint qr.get_module(x, y) ...)
182    }
183}
184```
185
186
187License
188-------
189
190Copyright © 2021 Project Nayuki. (MIT License)
191[https://www.nayuki.io/page/qr-code-generator-library](https://www.nayuki.io/page/qr-code-generator-library)
192
193Permission is hereby granted, free of charge, to any person obtaining a copy of
194this software and associated documentation files (the "Software"), to deal in
195the Software without restriction, including without limitation the rights to
196use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
197the Software, and to permit persons to whom the Software is furnished to do so,
198subject to the following conditions:
199
200* The above copyright notice and this permission notice shall be included in
201  all copies or substantial portions of the Software.
202
203* The Software is provided "as is", without warranty of any kind, express or
204  implied, including but not limited to the warranties of merchantability,
205  fitness for a particular purpose and noninfringement. In no event shall the
206  authors or copyright holders be liable for any claim, damages or other
207  liability, whether in an action of contract, tort or otherwise, arising from,
208  out of or in connection with the Software or the use or other dealings in the
209  Software.
210