{"record":{"id":"ede5e56f93364b20","repo":"iOfficeAI/OfficeCLI","slug":"propname-contains-the-xml-illegal-noncharacter-u","errorCode":null,"errorMessage":"{propName} contains the XML-illegal noncharacter U+{(int)c:X4} at position {i}.","messagePattern":"(.+?) contains the XML-illegal noncharacter U\\+(.+?) at position (.+?)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/ParseHelpers.cs","lineNumber":869,"sourceCode":"                throw new ArgumentException(\n                    $\"{propName} contains XML-illegal control character U+{(int)c:X4} at position {i}. \" +\n                    \"Allowed control chars: \\\\t, \\\\n, \\\\r\" +\n                    (allowSoftBreakChar ? \", \\\\v.\" : \".\"));\n            // UTF-16 surrogates only valid in pairs (high then low). A lone\n            // half is illegal in XML 1.0 character data.\n            if (char.IsHighSurrogate(c))\n            {\n                if (i + 1 >= value.Length || !char.IsLowSurrogate(value[i + 1]))\n                    throw new ArgumentException(\n                        $\"{propName} contains an unpaired high surrogate U+{(int)c:X4} at position {i}. Use a complete UTF-16 surrogate pair.\");\n                i++; // skip the matched low surrogate\n                continue;\n            }\n            if (char.IsLowSurrogate(c))\n                throw new ArgumentException(\n                    $\"{propName} contains an unpaired low surrogate U+{(int)c:X4} at position {i}. Use a complete UTF-16 surrogate pair.\");\n            if (c == 0xFFFE || c == 0xFFFF)\n                throw new ArgumentException(\n                    $\"{propName} contains the XML-illegal noncharacter U+{(int)c:X4} at position {i}.\");\n        }\n    }\n}\n","sourceCodeStart":851,"sourceCodeEnd":874,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/ParseHelpers.cs#L851-L874","documentation":"Thrown by ValidateXmlText when the value contains U+FFFE or U+FFFF. These are Unicode noncharacters explicitly disallowed in XML 1.0 character data. (U+FFFE is also a byte-order-marker noncharacter; both are reserved and never legal text content.)","triggerScenarios":"Setting any text value that contains the literal U+FFFE or U+FFFF character — e.g. binary/marker data decoded into a string, or test fixtures that include these code points.","commonSituations":"A BOM noncharacter (U+FFFE) left after mis-decoding bytes; sentinel/filler values from another system that uses U+FFFF as a 'no value' marker; fuzz-test inputs.","solutions":["Remove U+FFFE and U+FFFF from the string before setting the value.","Fix the upstream decoding that produced a U+FFFE (often a wrong byte order / misread BOM).","Replace sentinel characters with a valid placeholder before submission."],"exampleFix":"// before\nvar text = \"data\\uFFFF\";\n// after\nvar text = \"data\";          // U+FFFF removed","handlingStrategy":"validation","validationCode":"static string RemoveXmlNoncharacters(string s)\n    => s.Replace(\"\\uFFFE\", string.Empty).Replace(\"\\uFFFF\", string.Empty);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter U+FFFE and U+FFFF from text before submission.","Fix upstream byte-order/decoding issues that produce U+FFFE.","Replace sentinel characters from other systems with valid placeholders."],"tags":["xml","input-validation","unicode","noncharacter","ooxml","officecli"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}