How to Encode QR Code Data in C#
C#.NET QR Code Generator is exclusively built for Quick Response Code (QR Code) automotive industry and business. It provides an easy way to create and stream QR Code images to Client and Web projects developed in Visual C# IDEs.
C#.NET QR Code Generator DLL generates QR Code with its valid characters set using 6 different data mode. It also creates 8-bits Codewords to use the ReedâSolomon error correction algorithm with four error correction levels. Here is a detailed data encoding sample coding of QR Code, if you want to QR Code size and image setting in C#.NET, please see:
QR Code Data Related Properties
Data Mode
Users may easily generate QR Code barcodes using
Data Mode property.
6 QR Code data modes:
- Auto: encodes all 256 possible 8-bit byte values
- Alphanumeric: encodes uppercase and lower case letters Aa-Zz
- Byte: encodes 8-bit values according to ISO/IEC 8859-1
- Numeric: encodes 10 Arabic digits 0-9
- KanjI: encodes Kanji characters
- Customer: encodes data according to the customer
Code
Users may easily change QR Code barcode data string with variable length using Code property.
ProcessTilde
Users may simply encode some special characters in QR Code barcode with a tilde characters "~" using
ProcessTilde property.
- 1-byte character: ~0dd/~1dd/~2dd (character value from 000 ~ 255); ASCII character '~' is presented by ~126
Strings from "~256" to "~299" are unused
- 2-byte character (Unicode): ~6ddddd (character value from 00000 ~ 65535)
Strings from "~665536" to "~699999" are unused
- for GS1 AI Code:
- ECI: ~7dddddd (valid value of dddddd from 000000 to 999999)
- SJIS: from ~9ddddd (Shift JIS 0x8140 ~ 0x9FFC and 0xE040 ~ 0xEBBF)
Error Correction Level
Users may encode QR Codes with four different levels of error corrections: L, M, H, and Q using ECL property.
Encode QR Code Barcode Data in C#.NET
If you want to encode QR Code data in C#.NET, be sure that you have installed:
- Microsoft .NET Framework 2.0/3.0/4.0
- Microsoft Visual Studio 2005/2008/2010 (Express, Professional & Standard Edition)
- Barcode Generator for .NET Ultimate installed
Encode QR Code Barcode Data in .NET Project Using C# Class
Copy those following code onto your C#.NET projects:
using BusinessRefinery.Barcode;
QRCode barcode = new QRCode();
barcode.Code = "0123456789";
barcode.drawBarcode2ImageFile("c:/qr-code-csharp.gif");
Encode QR Code Barcode Data with Different Data Modes in C#.NET
DataMode default value in Barcode Generator for .NET Ultimate is QRCodeDataMode.Auto.
Copy those following code to change QR Code encoding data modes:
Barcode.DataMode = QRCodeDataMode.AlphaNumeric;
barcode.Code = "QR-Code";
Select QR Code Error Correction Level
ECL default value in Barcode Generator for .NET Ultimate is QRCodeECL.L.
Copy those following code to change QR Code error correction level:
barcode.ECL = QRCodeECL.H;
Encode QR Code Barcode Data with "~" in C#.NET
ProcessTilde default value in Barcode Generator for .NET Ultimate is false.
Copy those following code to encode QR Code barcode data with "~":
barcode.ProcessTilde= true;
barcode.Code = "~458964";