Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Error decoding some QR codes with error correction level H

Open
#506 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
backend

Research direction

Start from the reproduction in the issue: a BarcodeWriter producing a QR code at QrVersion 6 with ErrorCorrection H, then a BarcodeReader with PossibleFormats set to QR_CODE, using the WIFI string with and without a suffix. Run it at pixel sizes 4 and 8 to confirm the failure, then find which decoder stage rejects the image. Done means that exact string decodes at level H for all pixel sizes, with a regression test covering it.

Written by the indexing model from the issue text.

Description

First of all, thanks for a great library. I have discovered an issue decoding QR codes using error correction level H. I'm running the latest version 0.16.9 from NuGet.

      BarcodeWriter writer = new BarcodeWriter()
      {
        Format = BarcodeFormat.QR_CODE,
      };

      BarcodeReader reader = new BarcodeReader()
      {
        Options = new DecodingOptions()
        {
          PossibleFormats = new List<BarcodeFormat>()
          {
            BarcodeFormat.QR_CODE,
          },
        },
      };

      Trace.WriteLine($"Level\tPixel size\tSuffix\tSuccess");
      foreach(ErrorCorrectionLevel level in new[] { ErrorCorrectionLevel.L, ErrorCorrectionLevel.M, ErrorCorrectionLevel.Q, ErrorCorrectionLevel.H })
      {
        foreach(int pixelSize in new[] { 2, 4, 8 })
        {
          foreach(string suffix in new[] { "", "suffix" })
          {
            writer.Options = new QrCodeEncodingOptions()
            {
              QrVersion = 6,
              ErrorCorrection = level,
              Width  = 49 * pixelSize,
              Height = 49 * pixelSize,
            };

            using Bitmap bmp = writer.Write("WIFI:S:Maskinutbildning;T:WPA;P:fWpzCSgnxe;;" + suffix);
            Result result = reader.Decode(bmp);
            Trace.WriteLine($"{level}\t{pixelSize}\t{suffix.Length > 0}\t{result != null}");
          }
        }
      }

This produces the output:

Level	Pixel size	Suffix	Success
L	2	False	True
L	2	True	True
L	4	False	True
L	4	True	True
L	8	False	True
L	8	True	True
M	2	False	True
M	2	True	True
M	4	False	True
M	4	True	True
M	8	False	True
M	8	True	True
Q	2	False	True
Q	2	True	True
Q	4	False	True
Q	4	True	True
Q	8	False	True
Q	8	True	True
H	2	False	True
H	2	True	True
H	4	False	False
H	4	True	True
H	8	False	False
H	8	True	True

As you can see, error correction level H is only decoded correctly when using pixel size 2. The strange thing is that if I add some more text to the QR code it decodes fine. Also if I change the password field to something other. So I guess that this exact string creates some difficult pattern in the code.

I tried an online QR code generator with the same string and error correction level H which is also not decoded by ZXing.Net.

Dominant language
C#
Stars
3.1k
Forks
704
Avg merge
13d 17h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from micjahn/ZXing.Net

All issues in micjahn/ZXing.Net

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.