iOfficeAI/OfficeCLI · error · ArgumentException
{propName} contains the XML-illegal noncharacter U+{(int)c:X
Error message
{propName} contains the XML-illegal noncharacter U+{(int)c:X4} at position {i}. What it means
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.)
Source
Thrown at src/officecli/Core/ParseHelpers.cs:869
throw new ArgumentException(
$"{propName} contains XML-illegal control character U+{(int)c:X4} at position {i}. " +
"Allowed control chars: \\t, \\n, \\r" +
(allowSoftBreakChar ? ", \\v." : "."));
// UTF-16 surrogates only valid in pairs (high then low). A lone
// half is illegal in XML 1.0 character data.
if (char.IsHighSurrogate(c))
{
if (i + 1 >= value.Length || !char.IsLowSurrogate(value[i + 1]))
throw new ArgumentException(
$"{propName} contains an unpaired high surrogate U+{(int)c:X4} at position {i}. Use a complete UTF-16 surrogate pair.");
i++; // skip the matched low surrogate
continue;
}
if (char.IsLowSurrogate(c))
throw new ArgumentException(
$"{propName} contains an unpaired low surrogate U+{(int)c:X4} at position {i}. Use a complete UTF-16 surrogate pair.");
if (c == 0xFFFE || c == 0xFFFF)
throw new ArgumentException(
$"{propName} contains the XML-illegal noncharacter U+{(int)c:X4} at position {i}.");
}
}
}
View on GitHub (pinned to 1ced45e900)
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.
Example fix
// before var text = "data\uFFFF"; // after var text = "data"; // U+FFFF removed
Defensive patterns
Strategy: validation
Validate before calling
static string RemoveXmlNoncharacters(string s)
=> s.Replace("\uFFFE", string.Empty).Replace("\uFFFF", string.Empty); Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {propName} contains an unpaired high surrogate U+{(int)c:X4}
- {propName} contains an unpaired low surrogate U+{(int)c:X4}
- {propName} contains XML-illegal control character U+{(int)c:
- Invalid '{propertyName}' value '{value}': degrees must be in
- Invalid color value: '{value}'. Expected 6-digit hex RGB (e.
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/ede5e56f93364b20.
Report an issue: GitHub.