encodeToString
Writes problem as an application/problem+xml document, always in UTF-8.
Not every Problem can be written. Appendix B puts each extension member in an element name, and XML constrains both names and character content in ways JSON does not. A problem this library encodes to JSON without complaint may be refused here. That asymmetry is deliberate. Problem accepts any extension name because RFC 9457 §3.2's naming rule is a SHOULD, and enforcing it in the model would break JSON-only callers for the sake of a format they never use.
Throws
if problem nests deeper than Problem.MAX_NESTING_DEPTH; if an extension member's name is not an XML NCName (XML 1.0 §2.3 without a colon); or if any member's text carries U+0000 or an unpaired surrogate, neither of which XML can represent. The underlying writer's own exception, where there is one, is attached as the cause.