SubtitleEdit/subtitleedit · warning · InvalidOperationException
Unknown byte ({buffer[index]}) in subtitle file @ binary off
Error message
Unknown byte ({buffer[index]}) in subtitle file @ binary offset {index}. What it means
Thrown by Pac.GetArabicString when a byte in the stream does not map to any known Arabic (or combined Arabic) character and the static flag Pac.ThrowOnError is true. Without the flag (the default false) it silently returns an empty string instead. The message reports the offending byte value and the binary offset.
Source
Thrown at src/libse/SubtitleFormats/Pac.cs:2521
{
var arabicCharacter = GetNextArabicCharacter(buffer, ref index);
if (arabicCharacter.HasValue && arabicCharacter.Value.SwitchOrder)
{
// if we have a special character we must fetch the next one and move it before the current special one
var tempIndex = index + 1;
var nextArabicCharacter = GetNextArabicCharacter(buffer, ref tempIndex);
if (buffer[tempIndex] >= 0x80 && nextArabicCharacter != null)
{
index = tempIndex;
var combined = $"{nextArabicCharacter.Value.Character}{arabicCharacter.Value.Character}";
return combined;
}
}
if (ThrowOnError && !arabicCharacter.HasValue)
{
throw new InvalidOperationException($"Unknown byte ({buffer[index]}) in subtitle file @ binary offset {index}.");
}
return arabicCharacter.HasValue
? arabicCharacter.Value.Character
: string.Empty;
}
private static SpecialCharacter? GetNextArabicCharacter(byte[] buffer, ref int index)
{
if (index >= buffer.Length)
{
return null;
}
var b = buffer[index];
SpecialCharacter? arabicCharacter = null;
if (ArabicCodes.ContainsKey(b))
{View on GitHub (pinned to 17a9f07487)
Solutions
- Leave Pac.ThrowOnError at its default false to tolerate unmapped bytes (they become empty).
- Verify the file is genuinely an Arabic PAC and not a different language track.
- Re-export or re-acquire the PAC file if byte corruption is suspected.
- If strictness is required, extend the Arabic code map to cover the offending byte.
Example fix
// before (strict) Pac.ThrowOnError = true; // after (tolerant, default) Pac.ThrowOnError = false;
Defensive patterns
Strategy: validation
Validate before calling
// Keep ThrowOnError false (default) so unmapped bytes are skipped, not thrown Pac.ThrowOnError = false; new Pac().LoadSubtitle(sub, lines, fileName); // Set true only for strict one-off audits
Try / catch
Pac.ThrowOnError = true;
try
{
new Pac().LoadSubtitle(sub, lines, fileName);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Unknown byte"))
{
// ex.Message reports the byte value and binary offset
logger.Warning(ex.Message);
} Prevention
- Leave Pac.ThrowOnError false for normal loads.
- Confirm the file's language is Arabic before decoding.
- Re-acquire PAC files from source if bytes look corrupt.
When it happens
Trigger: Decoding a PAC file in Arabic codepage where a byte falls outside the Arabic glyph table and cannot be combined with the following byte into a ligature. ThrowOnError=true converts the silent skip into a hard failure for strict validation.
Common situations: PAC files with embedded non-Arabic glyphs in an Arabic track, mixed-language content, corrupt glyph bytes, or a codepage misclassification (the file is not actually Arabic).
Related errors
- Unknown byte ({b}) in subtitle file @ binary offset {index}.
- Unknown byte (0x{b:X2}) in subtitle file @ binary offset {in
- Error in paragraph {p.StartTime} after '{sb}': {ex.Message}
- Invalid ASSA time code: {time}
- Unknown time format '{timeFormat}'
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/df7fbe50eee72f9b.
Report an issue: GitHub.