c# QR code supports Chinese

/// <summary>
/// Generate a QR code and save it as a picture
/// </summary>
static void Generate1(string text)
{
    BarcodeWriter writer = new BarcodeWriter();
    writer.Format = BarcodeFormat.QR_CODE;
    QrCodeEncodingOptions options = new QrCodeEncodingOptions();
    options.DisableECI = true;
    //set content encoding
    options.CharacterSet = "UTF-8";
    //Set the width and height of the QR code
    options.Width = 500;
    options.Height = 500;
    //Set the margin of the QR code, the unit is not a fixed pixel
    options.Margin = 1;
    writer.Options = options;

    Bitmap map = writer.Write(text);
    string filename = @"H:\Desktop\Screenshot\generate1.png";
    map.Save(filename, ImageFormat.Png);
    map.Dispose();
}
copy code

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325184756&siteId=291194637