{"record":{"id":"1b4a2fe62b33520b","repo":"SubtitleEdit/subtitleedit","slug":"unknown-byte-0x-b-x2-in-subtitle-file-binary","errorCode":null,"errorMessage":"Unknown byte (0x{b:X2}) in subtitle file @ binary offset {index}.","messagePattern":"Unknown byte \\(0x(.+?)\\) in subtitle file @ binary offset (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"src/libse/SubtitleFormats/Pac.cs","lineNumber":2663,"sourceCode":"\n            if (buffer.Length > index + 1)\n            {\n                var code = b * 256 + buffer[index + 1];\n                if (CyrillicCodes.ContainsKey(code))\n                {\n                    index++;\n                    return CyrillicCodes[code].Character;\n                }\n            }\n\n            if (CyrillicCodes.ContainsKey(b))\n            {\n                return CyrillicCodes[b].Character;\n            }\n\n            if (ThrowOnError)\n            {\n                throw new InvalidOperationException($\"Unknown byte (0x{b:X2}) in subtitle file @ binary offset {index}.\");\n            }\n\n            return string.Empty;\n        }\n\n        public static string GetGreekString(byte[] buffer, ref int index, bool isSecondary)\n        {\n            var b = buffer[index];\n\n            if (b >= 0x30 && b <= 0x39) // decimal digits\n            {\n                return Encoding.ASCII.GetString(buffer, index, 1);\n            }\n\n            if (isSecondary && (buffer[index] == 0x2d || buffer[index] == 0x5f))\n            {\n                return GetLatinString(Encoding.ASCII, buffer, ref index, new Dictionary<int, SpecialCharacter>());\n            }","sourceCodeStart":2645,"sourceCodeEnd":2681,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libse/SubtitleFormats/Pac.cs#L2645-L2681","documentation":"Thrown by Pac.GetCyrillicString when a byte (or its two-byte sequence) does not map in CyrillicCodes and Pac.ThrowOnError=true. Decimal digits 0x30-0x39 pass through as ASCII first. The message uses hex (0xNN) format for the byte. Default false returns empty.","triggerScenarios":"Decoding a PAC Cyrillic track where a byte or byte-pair has no CyrillicCodes entry and is not a digit — e.g. an unmapped high byte or a broken two-byte sequence. Only throws when ThrowOnError is enabled.","commonSituations":"Misidentified language (file is not Russian/Cyrillic), corrupt bytes, or a Cyrillic variant whose glyph table differs from this build.","solutions":["Keep Pac.ThrowOnError = false to skip unmapped bytes.","Verify the file is a Cyrillic-language PAC.","Re-export/re-acquire the file if corruption is suspected.","Extend CyrillicCodes for legitimate but unmapped glyphs."],"exampleFix":"// before\nPac.ThrowOnError = true;\n// after\nPac.ThrowOnError = false;","handlingStrategy":"validation","validationCode":"// Tolerant mode skips unmapped Cyrillic bytes\nPac.ThrowOnError = false;\nnew Pac().LoadSubtitle(sub, lines, fileName);","typeGuard":null,"tryCatchPattern":"Pac.ThrowOnError = true;\ntry\n{\n    new Pac().LoadSubtitle(sub, lines, fileName);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Unknown byte\"))\n{\n    logger.Warning(ex.Message); // hex byte and offset included\n}","preventionTips":["Keep Pac.ThrowOnError false for production decoding.","Confirm the file is a Cyrillic-language PAC.","Extend CyrillicCodes for legitimate unmapped glyphs."],"tags":["subtitle-format","pac","binary","cyrillic","encoding","byte-mapping"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}