normalizeChar function
Corrects common OCR errors for a single character based on context.
Implementation
String normalizeChar(String char, {bool isDigit = false, bool isAlpha = false}) {
const toDigitMap = {'O': '0', 'I': '1', 'L': '1', 'S': '5', 'B': '8', 'G': '6', 'Z': '2', 'Q': '0', 'D': '0'};
const toAlphaMap = {'0': 'O', '1': 'I', '5': 'S', '8': 'B', '6': 'G', '2': 'Z'};
if (isDigit) return toDigitMap[char] ?? char;
if (isAlpha) return toAlphaMap[char] ?? char;
return char;
}