{"record":{"id":"bec6fe07f6610698","repo":"SubtitleEdit/subtitleedit","slug":"pac-code-page-is-empty","errorCode":null,"errorMessage":"PAC code page is empty.","messagePattern":"PAC code page is empty\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/seconv/Core/PacCodepageParser.cs","lineNumber":36,"sourceCode":"        [\"Arabic\"] = Pac.CodePageArabic,\n        [\"Hebrew\"] = Pac.CodePageHebrew,\n        [\"Thai\"] = Pac.CodePageThai,\n        [\"Cyrillic\"] = Pac.CodePageCyrillic,\n        [\"ChineseTraditional\"] = Pac.CodePageChineseTraditional,\n        [\"ChineseSimplified\"] = Pac.CodePageChineseSimplified,\n        [\"Korean\"] = Pac.CodePageKorean,\n        [\"Japanese\"] = Pac.CodePageJapanese,\n        [\"LatinTurkish\"] = Pac.CodePageLatinTurkish,\n        [\"Turkish\"] = Pac.CodePageLatinTurkish,\n        [\"LatinPortuguese\"] = Pac.CodePageLatinPortuguese,\n        [\"Portuguese\"] = Pac.CodePageLatinPortuguese,\n    };\n\n    public static int Parse(string input)\n    {\n        if (string.IsNullOrWhiteSpace(input))\n        {\n            throw new FormatException(\"PAC code page is empty.\");\n        }\n\n        var s = input.Trim();\n        if (Named.TryGetValue(s, out var named))\n        {\n            return named;\n        }\n\n        if (int.TryParse(s, NumberStyles.None, CultureInfo.InvariantCulture, out var num) &&\n            num >= Pac.CodePageLatin && num <= Pac.CodePageLatinPortuguese)\n        {\n            return num;\n        }\n\n        throw new FormatException(\n            $\"PAC code page '{input}' is invalid. Expected a name (Latin, Greek, ...) or a number 0-12.\");\n    }\n}","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/seconv/Core/PacCodepageParser.cs#L18-L54","documentation":"Thrown by PacCodepageParser.Parse when the `--pac-codepage` value is null/empty/whitespace. PAC (Philips SVCD caption) files are encoded using a code page; the parser needs a name (Latin, Greek, ...) or a numeric code to decode bytes, and an empty string cannot resolve to either.","triggerScenarios":"Calling `PacCodepageParser.Parse(input)` with an empty string, typically because `--pac-codepage=` was passed without a value.","commonSituations":"Shell expansion blanking the value; wrapper script defaulting to empty; user assumes there is a default code page but PAC requires an explicit one for non-Latin content.","solutions":["Pass a named code page, e.g. `--pac-codepage=Latin`.","Or pass a numeric code in the valid range, e.g. `--pac-codepage=0`.","Omit the flag if your workflow does not read PAC files.","Guard scripts to only emit the flag when the variable is non-empty."],"exampleFix":"# before\nseconv in.pac out.srt --pac-codepage=\n# after\nseconv in.pac out.srt --pac-codepage=Latin","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(rawPac))\n    throw new ArgumentException(\"--pac-codepage requires a value\");\nvar cp = PacCodepageParser.Parse(rawPac);","typeGuard":"static bool IsPacCodepageParsable(string? s)\n{\n    if (string.IsNullOrWhiteSpace(s)) return false;\n    try { PacCodepageParser.Parse(s); return true; } catch { return false; }\n}","tryCatchPattern":"try { var cp = PacCodepageParser.Parse(input); }\ncatch (FormatException ex) when (ex.Message == \"PAC code page is empty.\")\n{\n    // default to Latin or abort\n}","preventionTips":["Default to a sensible code page (e.g. Latin) when none is supplied.","Length-check the input before parsing.","Validate at arg-parse time for PAC inputs only."],"tags":["cli","parsing","pac","codepage","configuration"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}