Summary#
Qr.Encode(text) returns a QR code for text as a List<string>: one string per row, top to bottom, each character
a module — '1' dark, '0' light. Every row is as long as the list, so a code is rows.Count modules a side.
Signature#
Qr.Encode(<string> text) -> List<string>Description#
What it makes#
Byte mode (the text as UTF-8), error correction level M (about 15 % of the code may be damaged and still read), in the smallest version that holds the text, with the mask the standard's penalty scores best. Text too long for any version (over 2,328 bytes) is refused with the limit in the message.
Drawing it#
Draw the modules dark on light whatever the page's colours, with a light margin of four modules on every side —
a reader looks for three dark finder squares on a light ground, and a code drawn light-on-dark or cropped tight reads
on nothing. A row is cheapest to draw as its runs: a Row of boxes, one per stretch of the same colour.
Why it runs on the server#
The text a code carries is usually made on the server — a provider's frame derived from a secret the browser must never hold, like BankID's animated QR, which changes every second. So the encoder is native to the server, and the page is sent the rows. It is fast enough to redraw every second for every viewer.
Examples#
class Code { public List<string> Rows = []; public int Side; }
Code ForScanning(string text) {
var rows = Qr.Encode(text);
return new Code { Rows = rows, Side = rows.Count };
}
// ForScanning("HELLO WORLD").Side -> 21 (version 1)See also#
- publishing a REST API (app.Apis) —
Request.ClientAddress, the other half of a BankID flow the server runs - Text.Split — other in-memory string builtins