{"record":{"id":"d74f92eb22c72bf5","repo":"SubtitleEdit/subtitleedit","slug":"resolution-input-is-invalid-expected-widthxhe","errorCode":null,"errorMessage":"Resolution '{input}' is invalid. Expected WIDTHxHEIGHT, e.g. 1920x1080.","messagePattern":"Resolution '(.+?)' is invalid\\. Expected WIDTHxHEIGHT, e\\.g\\. 1920x1080\\.","errorType":"validation","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/seconv/Core/ResolutionParser.cs","lineNumber":22,"sourceCode":"\n/// <summary>\n/// Parses <c>WIDTHxHEIGHT</c> strings (e.g. <c>1920x1080</c>) used by <c>--resolution</c>.\n/// Both lowercase <c>x</c> and uppercase <c>X</c> are accepted.\n/// </summary>\ninternal static class ResolutionParser\n{\n    public static (int Width, int Height) Parse(string input)\n    {\n        if (string.IsNullOrWhiteSpace(input))\n        {\n            throw new FormatException(\"Resolution is empty.\");\n        }\n\n        var s = input.Trim();\n        var idx = s.IndexOfAny(['x', 'X']);\n        if (idx <= 0 || idx == s.Length - 1)\n        {\n            throw new FormatException($\"Resolution '{input}' is invalid. Expected WIDTHxHEIGHT, e.g. 1920x1080.\");\n        }\n\n        var wPart = s[..idx];\n        var hPart = s[(idx + 1)..];\n\n        if (!int.TryParse(wPart, NumberStyles.None, CultureInfo.InvariantCulture, out var w) ||\n            !int.TryParse(hPart, NumberStyles.None, CultureInfo.InvariantCulture, out var h) ||\n            w <= 0 || h <= 0)\n        {\n            throw new FormatException($\"Resolution '{input}' is invalid. Width and height must be positive integers.\");\n        }\n\n        return (w, h);\n    }\n}\n","sourceCodeStart":4,"sourceCodeEnd":38,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/seconv/Core/ResolutionParser.cs#L4-L38","documentation":"Thrown by ResolutionParser.Parse when the trimmed input has no 'x'/'X' separator in a valid position (index <= 0 means no leading width, index == last means no trailing height). FormatException because the structural shape is wrong even before integer parsing.","triggerScenarios":"Calling `ResolutionParser.Parse(input)` with values like '1920', 'x1080', '1920x' (missing one side), '1920X1080' works (X is allowed), but '1920-1080' or '1920×1080' (Unicode multiply) fails.","commonSituations":"Using a hyphen or en-dash instead of 'x'; using the Unicode multiplication sign × (copy-paste from a formatted doc); passing only one dimension; trailing units like '1920x1080p'.","solutions":["Use the literal ASCII 'x' or 'X' between width and height: `1920x1080`.","Remove any suffix like 'p' or 'i' — pass only numbers.","If copying from documentation, retype the separator to avoid Unicode lookalikes.","Provide both dimensions; do not omit either side."],"exampleFix":"# before\nseconv in.sup out.bdnxml --resolution=1920×1080   # unicode multiply\n# after\nseconv in.sup out.bdnxml --resolution=1920x1080","handlingStrategy":"validation","validationCode":"var sepIdx = input.IndexOfAny(new[] { 'x', 'X' });\nif (sepIdx <= 0 || sepIdx == input.Length - 1)\n    throw new ArgumentException(\"--resolution must be WIDTHxHEIGHT, e.g. 1920x1080\");","typeGuard":"static bool HasValidResolutionShape(string? s)\n{\n    if (string.IsNullOrWhiteSpace(s)) return false;\n    var i = s.IndexOfAny(new[] { 'x', 'X' });\n    return i > 0 && i < s.Length - 1;\n}","tryCatchPattern":"try { var res = ResolutionParser.Parse(input); }\ncatch (FormatException ex) when (ex.Message.Contains(\"Expected WIDTHxHEIGHT\"))\n{\n    // reject and show example\n}","preventionTips":["Normalize Unicode lookalikes (×, multiply sign) to ASCII 'x' before parsing.","Reject hyphen/dash separators at arg-parse time.","Strip trailing 'p'/'i' before validation if your CLI accepts them."],"tags":["cli","parsing","resolution","format-validation"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}