---
title: "Disable OCR corrections for IDs in C#"
url: https://recursiveai.org/oneocr/cookbook/disable-character-corrections-for-identifiers/
description: "Keep OCR from rewriting O as 0 in mixed identifiers or correcting standalone separators. Compare both OneOcr settings on a local PNG."
version: "1.0.0"
---

# Disable OCR corrections for IDs in C#

**OneOcr** is a free, open-source OCR library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneOcr) · [GitHub](https://github.com/recursive-ai-oss/oneocr-csharp) · [Docs](https://recursiveai.org/oneocr/docs/) · [Download example (.zip)](https://recursiveai.org/oneocr/cookbook/disable-character-corrections-for-identifiers/disable-character-corrections-for-identifiers.zip)

Stop OCR cleanup from changing letter O to zero in IDs. Try `identifiers.png` from the zip.

```shell
dotnet add package RecursiveAI.OneOcr
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using OneImage;
using OneOcr;

var engine = OcrEngine.LoadBundled();
var image = Image.Load("identifiers.png");
var page = image.Ocr(engine, new OcrOptions
{
    FixDigitLookalikes = false,
    FixSeparators = false
});
Console.WriteLine(page.ToText());
```

Unzip [the example](https://recursiveai.org/oneocr/cookbook/disable-character-corrections-for-identifiers/disable-character-corrections-for-identifiers.zip), then `dotnet run`.

Prints the recognized text with digit-lookalike and separator correction turned off:

```text
ACC-71O3O5 · LOT-2048
I
SHIP-4O16 | BIN-38
2020-04-O7
```

With corrections off, `ACC-71O3O5` has capital O’s at positions 3 and 5 after the hyphen. The standalone `I` is a recognition error: it isn’t in the image.

`using OneImage;` imports `Image` from `RecursiveAI.OneImage`, which `RecursiveAI.OneOcr` installs as a dependency.

## The full program

The generated image contains this text. The round characters in `71O3O5`, `4O16` and `O7` are capital O’s.

```text
ACC-71O3O5 · LOT-2048
SHIP-4O16 | BIN-38
2020-04-O7
```

The program reads the same image twice with the bundled engine and prints the settings and page diagnostics for both runs.

```csharp
using OneImage;
using OneOcr;

var engine = OcrEngine.LoadBundled();
var image = Image.Load("identifiers.png");
foreach (bool fix in new[] { true, false })
{
    var options = new OcrOptions
    {
        FixDigitLookalikes = fix,
        FixSeparators = fix
    };
    var page = image.Ocr(engine, options);
    Console.WriteLine($"FixDigitLookalikes={fix}, FixSeparators={fix}");
    Console.WriteLine(page.ToText());
    Console.WriteLine($"Diagnostics: {page.Diagnostics.Count}");
    foreach (var note in page.Diagnostics)
        Console.WriteLine($"{note.Code}: {note.Message}");
}
```

`dotnet run` prints:

```text
FixDigitLookalikes=True, FixSeparators=True
ACC-710305 · LOT-2048
I
SHIP-4016 | BIN-38
2020-04-07
Diagnostics: 1
OCR101: UnitsPerInch is estimated at 200 from the size of the text; pass OcrOptions.Dpi to set it.
FixDigitLookalikes=False, FixSeparators=False
ACC-71O3O5 · LOT-2048
I
SHIP-4O16 | BIN-38
2020-04-O7
Diagnostics: 1
OCR101: UnitsPerInch is estimated at 200 from the size of the text; pass OcrOptions.Dpi to set it.
```

With corrections on, `ACC-710305` has zeros at positions 3 and 5 after the hyphen. With corrections off, `ACC-71O3O5` has capital O’s in those positions. The digit rule changed three tokens in this run; the middle dot and vertical bar were read the same way in both runs. `OCR101` reports an estimated image resolution, not which characters changed. If a file can’t be decoded, OneOcr throws `OcrFormatException`; an incorrect character in a valid image doesn’t have to raise an error or a diagnostic.

## Variations

**Disable accent cleanup as well.** Replace the options in the snippet at the top if accents or dots are meaningful parts of your identifiers.

```csharp
var options = new OcrOptions
{
    FixDigitLookalikes = false,
    FixSeparators = false,
    FixStrayAccents = false
};
Console.WriteLine(image.Ocr(engine, options).ToText());
```

## Related recipes

- [Extract text from an image](https://recursiveai.org/oneocr/cookbook/extract-text-from-image/)
- [Extract key-value pairs from an image](https://recursiveai.org/oneocr/cookbook/extract-key-value-pairs-from-image/)

## The short answer

Set `FixDigitLookalikes = false` and `FixSeparators = false` on the `OcrOptions` passed to `Ocr`. This prevents those two rules from changing the recognizer’s characters. It doesn’t make a wrong recognition right: if the OCR model already read a letter as a digit, turning off a later rewrite won’t restore the letter. The variation also disables stray-accent cleanup.

## Why does OCR read the letter O as zero in identifiers?

There are two places it can happen. The model can mistake the shapes for each other, or OneOcr’s digit rule can rewrite what the model read. The [option’s documentation](https://github.com/recursive-ai-oss/oneocr-csharp/blob/8db430fb77c4d86d51686f15dfd9b5ccc20c99a7/src/OneOcr/OcrOptions.cs#L67-L75) describes the latter: a word with at least three digits can have its `O` changed to `0` in a run made entirely of digits and capital `O`s. It doesn’t touch `CO2` or short `O2`. A rule that helps with dates can be wrong for a serial number that legally contains letters in the same positions as digits. In the sample, `2020-04-07` is plausible as a date but is not what the image literally says.

## Does turning off character correction improve OCR accuracy?

No. It only stops the rewrite rules; it can’t fix a letter the recognizer misread. Compare the output against the known source or the formats your identifiers allow. If a field admits only digits, log or flag a suspicious letter for review; if both characters are valid, don’t normalize them globally. The [separator rule](https://github.com/recursive-ai-oss/oneocr-csharp/blob/8db430fb77c4d86d51686f15dfd9b5ccc20c99a7/src/OneOcr/OcrOptions.cs#L77-L85) handles single marks between words, not hyphens inside a code. Word spacing and noise removal are separate options, so turning off the two rules does not freeze whitespace or keep every speck read as a word. Compare text and diagnostics from both runs: the diagnostics can explain page-level conditions, but the text comparison tells you whether a particular identifier changed.
