{"record":{"id":"a7a4ce3b90d22b45","repo":"SubtitleEdit/subtitleedit","slug":"unknown-byte-b-in-subtitle-file-binary-offse","errorCode":null,"errorMessage":"Unknown byte ({b}) in subtitle file @ binary offset {index}.","messagePattern":"Unknown byte \\((.+?)\\) in subtitle file @ binary offset (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"src/libse/SubtitleFormats/Pac.cs","lineNumber":2576,"sourceCode":"            return arabicCharacter;\n        }\n\n        public static string GetHebrewString(byte[] buffer, ref int index)\n        {\n            var b = buffer[index];\n            if (b >= 0x20 && b < 0x80 && b != 44)\n            {\n                return Encoding.ASCII.GetString(buffer, index, 1);\n            }\n\n            if (HebrewCodes.ContainsKey(b))\n            {\n                return HebrewCodes[b].Character;\n            }\n\n            if (ThrowOnError)\n            {\n                throw new InvalidOperationException($\"Unknown byte ({b}) in subtitle file @ binary offset {index}.\");\n            }\n\n            return string.Empty;\n        }\n\n        private static bool TryGetMappedCharacter(Dictionary<int, SpecialCharacter> map, byte[] buffer, ref int index, out string result)\n        {\n            var b = buffer[index];\n\n            result = string.Empty;\n            if (map.ContainsKey(b))\n            {\n                result = map[b].Character;\n            }\n\n            if (buffer.Length > index + 2)\n            {\n                var code = b * 256 + buffer[index + 1];","sourceCodeStart":2558,"sourceCodeEnd":2594,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libse/SubtitleFormats/Pac.cs#L2558-L2594","documentation":"Thrown by Pac.GetHebrewString when a byte is not a printable ASCII (0x20-0x7F excluding comma 0x2C) and is not present in the HebrewCodes map, with Pac.ThrowOnError=true. The default (false) returns an empty string. Reports the byte value and offset.","triggerScenarios":"Decoding a PAC Hebrew track where a byte is outside the Hebrew glyph table and printable-ASCII range — e.g. a control byte, a comma (0x2C is explicitly excluded), or an unmapped high byte. Only throws when ThrowOnError is set.","commonSituations":"Codepage misclassification (file is not Hebrew), corrupt bytes, or a Hebrew variant whose glyph table differs from this build's HebrewCodes.","solutions":["Keep Pac.ThrowOnError = false (default) to skip unmapped bytes.","Confirm the file's language is Hebrew and select the correct codepage.","Re-acquire the file if corruption is likely.","Extend HebrewCodes for the unmapped byte if it is a legitimate glyph."],"exampleFix":"// before\nPac.ThrowOnError = true;\n// after\nPac.ThrowOnError = false;","handlingStrategy":"validation","validationCode":"// Tolerant mode skips unmapped Hebrew 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); // byte value and offset included\n}","preventionTips":["Keep Pac.ThrowOnError false for production decoding.","Verify the file is a Hebrew PAC track.","Extend HebrewCodes if a legitimate glyph is missing."],"tags":["subtitle-format","pac","binary","hebrew","encoding","byte-mapping"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}