{"record":{"id":"8355eba146f8b6d5","repo":"stride3d/stride","slug":"while-parsing-a-quoted-scalar-find-invalid-unicode-character","errorCode":null,"errorMessage":"While parsing a quoted scalar, find invalid Unicode character escape code.","messagePattern":"While parsing a quoted scalar, find invalid Unicode character escape code\\.","errorType":"exception","errorClass":"SyntaxErrorException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Scanner.cs","lineNumber":1688,"sourceCode":"                        {\n                            uint character = 0;\n\n                            // Scan the character value.\n\n                            for (int k = 0; k < codeLength; ++k)\n                            {\n                                if (!analyzer.IsHex(k))\n                                {\n                                    throw new SyntaxErrorException(start, mark, \"While parsing a quoted scalar, did not find expected hexdecimal number.\");\n                                }\n                                character = (uint) ((character << 4) + analyzer.AsHex(k));\n                            }\n\n                            // Check the value and write the character.\n\n                            if ((character >= 0xD800 && character <= 0xDFFF) || character > 0x10FFFF)\n                            {\n                                throw new SyntaxErrorException(start, mark, \"While parsing a quoted scalar, find invalid Unicode character escape code.\");\n                            }\n\n                            scanScalarValue.Append((char) character);\n\n                            // Advance the pointer.\n\n                            for (int k = 0; k < codeLength; ++k)\n                            {\n                                Skip();\n                            }\n                        }\n                    }\n                    else\n                    {\n                        // It is a non-escaped non-blank character.\n\n                        scanScalarValue.Append(ReadCurrentCharacter());\n                    }","sourceCodeStart":1670,"sourceCodeEnd":1706,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Scanner.cs#L1670-L1706","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nemoji: \"\\uD83D\\uDE00\"\n// after\nemoji: \"\\U0001F600\"","handlingStrategy":"validation","validationCode":"static bool IsValidUnicodeEscapeValue(uint v) => v <= 0x10FFFF && (v < 0xD800 || v > 0xDFFF);","typeGuard":null,"tryCatchPattern":"try\n{\n    var obj = Deserializer.FromText(yaml);\n}\ncatch (SyntaxErrorException ex)\n{\n    Log.Error(ex, \"Invalid Unicode escape code at {Start}\", ex.Start);\n    throw new YamlConfigException(\"YAML contains surrogate or out-of-range escape\", ex);\n}","preventionTips":["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"],"tags":["yaml","scanner","unicode","escape-sequence"],"backgroundTag":"yaml-parse-error","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}