{"record":{"id":"6d0b49ff6cf4c8db","repo":"tui-cs/Terminal.Gui","slug":"num-invalid-rune-not-a-scalar-unicode-value","errorCode":null,"errorMessage":"{num}: Invalid Rune (not a scalar Unicode value).","messagePattern":"(.+?): Invalid Rune \\(not a scalar Unicode value\\)\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/RuneJsonConverter.cs","lineNumber":130,"sourceCode":"                    string combined = string.Concat ((char)first, (char)second).Normalize ();\n\n                    if (!Rune.IsValid (combined [0]))\n                    {\n                        throw new JsonException ($\"{value}: Invalid combined Rune.\");\n                    }\n\n                    return new (combined [0]);\n                }\n            case JsonTokenType.Number:\n                {\n                    uint num = reader.GetUInt32 ();\n\n                    if (Rune.IsValid (num))\n                    {\n                        return new (num);\n                    }\n\n                    throw new JsonException ($\"{num}: Invalid Rune (not a scalar Unicode value).\");\n                }\n            case JsonTokenType.Null:\n                return default;\n            default:\n                throw new JsonException ($\"Unexpected token when parsing Rune: {reader.TokenType}.\");\n        }\n    }\n\n    public override void Write (Utf8JsonWriter writer, Rune value, JsonSerializerOptions options)\n    {\n        Rune printable = value.MakePrintable ();\n        if (printable == Rune.ReplacementChar)\n        {\n            // Write as /u string\n            writer.WriteRawValue ($\"\\\"{value}\\\"\");\n        }\n        else\n        {","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/RuneJsonConverter.cs#L112-L148","documentation":"A JSON number token is used where a Rune is expected, but the number is not a valid Unicode scalar value (in the surrogate range U+D800–U+DFFF, or greater than U+10FFFF). The converter accepts decimal numbers as codepoints (97 = 'a'), but invalid ranges are rejected by Rune.IsValid.","triggerScenarios":"Config has a numeric Rune value such as 55296 (0xD800), 1114112 (0x110000), or any number in the surrogate range.","commonSituations":"Authoring config with numeric codepoints and mistyping; copying a decimal from a surrogate listing; an off-by-one in hex→decimal conversion.","solutions":["Use a valid scalar codepoint number (0–55295 or 57344–1114111).","Switch to the \"U+XXXX\" string form to avoid decimal conversion errors.","Prefer the glyph or \\u string form for readability."],"exampleFix":"// before\n\"Glyph\": 55296\n// after\n\"Glyph\": 97   // or \"U+0061\"","handlingStrategy":"validation","validationCode":"static bool IsValidNumericRune (uint n) => System.Text.Rune.IsValid (n);","typeGuard":null,"tryCatchPattern":"try { ConfigurationManager.Apply (); }\ncatch (JsonException ex) when (ex.Message.Contains (\"not a scalar Unicode value\"))\n{ /* report offending number from ex.Message */ }","preventionTips":["Use the \"U+XXXX\" notation instead of raw decimal numbers to avoid conversion mistakes.","Cross-check numeric codepoints against Rune.IsValid in a scratch test."],"tags":["config","json","unicode","rune"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}