stride3d/stride · error · SyntaxErrorException
While parsing a quoted scalar, find invalid Unicode…
Error message
While parsing a quoted scalar, find invalid Unicode character escape code.
What it means
Thrown by the YAML Scanner when a Unicode escape sequence inside a quoted scalar decodes to a value that is not a valid scalar Unicode character: a surrogate code point (0xD800-0xDFFF) or anything above the Unicode maximum (0x10FFFF). The escape is syntactically well-formed hex but semantically cannot represent a character, so the scanner rejects it.
Solutions
- Replace the lone surrogate escape with the real code point, e.g. "\uD83D\uDE00" becomes "\U0001F600" (single escape for the combined character).
- Clamp or correct the escape value so it is <= 0x10FFFF and not in the D800-DFFF surrogate range.
- Put the actual character in the file (UTF-8 encoded YAML) instead of an escape sequence.
- Fix the upstream encoder that emitted surrogate-pair escapes into YAML.
Example fix
// before emoji: "\uD83D\uDE00" // after emoji: "\U0001F600"
Defensive patterns
Strategy: validation
Validate before calling
static bool IsValidUnicodeEscapeValue(uint v) => v <= 0x10FFFF && (v < 0xD800 || v > 0xDFFF);
Try / catch
try
{
var obj = Deserializer.FromText(yaml);
}
catch (SyntaxErrorException ex)
{
Log.Error(ex, "Invalid Unicode escape code at {Start}", ex.Start);
throw new YamlConfigException("YAML contains surrogate or out-of-range escape", ex);
} Prevention
- Never copy JSON surrogate-pair escapes (\uD83D\uDE00) into YAML; use one \U escape or the literal character
- Keep YAML files UTF-8 encoded with literal characters instead of escapes
- Lint generated YAML with a parser before writing it to disk
When it happens
Trigger: Parsing a YAML document whose quoted scalar contains escapes such as "\uD800" (lone surrogate, common when JSON-style surrogate pairs were copied verbatim) or "\u00110000" (value above 0x10FFFF).
Common situations: Converting JSON/JavaScript data to YAML where astral characters were encoded as surrogate pairs instead of a single code point; generated escape strings from buggy encoders; hand-written \U escapes with values past the Unicode range.
Related errors
- While parsing a quoted scalar, did not find expected…
- While scanning a simple key, could not find expected ':'.
- While scanning for the next token, find character that…
- While scanning a directive, find uknown directive name.
- While scanning a directive, did not find expected comment…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/8355eba146f8b6d5.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:1688
{
uint character = 0;
// Scan the character value.
for (int k = 0; k < codeLength; ++k)
{
if (!analyzer.IsHex(k))
{
throw new SyntaxErrorException(start, mark, "While parsing a quoted scalar, did not find expected hexdecimal number.");
}
character = (uint) ((character << 4) + analyzer.AsHex(k));
}
// Check the value and write the character.
if ((character >= 0xD800 && character <= 0xDFFF) || character > 0x10FFFF)
{
throw new SyntaxErrorException(start, mark, "While parsing a quoted scalar, find invalid Unicode character escape code.");
}
scanScalarValue.Append((char) character);
// Advance the pointer.
for (int k = 0; k < codeLength; ++k)
{
Skip();
}
}
}
else
{
// It is a non-escaped non-blank character.
scanScalarValue.Append(ReadCurrentCharacter());
}View on GitHub (pinned to 96fad776d2)