Nikolay Sivov (@nsivov) commented about dlls/xmllite/tests/writer.c:
- IStream *stream;
- HRESULT hr;
- hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
- ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- stream = writer_set_output(writer);
- writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
- hr = IXmlWriter_WriteStartElement(writer, NULL, L"chars", NULL);
- ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- /* Writes the whole string but returns an error, strange but true */
- hr = IXmlWriter_WriteChars(writer, L"<chars>", 20);
- ok(hr == WC_E_XMLCHARACTER, "Unexpected hr %#lx.\n", hr);
I don't think it's strange. It simply checks for valid characters in given input, following https://www.w3.org/TR/xml/#charsets:
`| [2] | Char | ::= | #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] |`
First character to fail this grammar is \0 in your input. The fact that it does not check everything before writing is probably to improve performance.