morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::wire::detail::EscapingWriteOpts Struct Reference

Write options that escape ASCII control bytes as \\uXXXX sequences. More...

#include <wire.hpp>

Public Attributes

bool escape_control_characters = true
 Emit control bytes as \\uXXXX rather than raw.

Detailed Description

Write options that escape ASCII control bytes as \\uXXXX sequences.

glaze 7.4 leaves control bytes unescaped by default, which breaks encode two different ways depending on where the byte lands:

  • Invalid output. RFC 8259 requires U+0000 through U+001F to be escaped, and glaze's own reader enforces that, so an envelope carrying a raw 0x0B anywhere serializes to JSON the peer's decode then throws on.
  • Silent corruption. Worse, the writer's chunked fast path mangles such a byte outright once the string also contains an escaped character: with a backslash or double-quote character earlier in the same string, a 0x0B at certain offsets is written as two 0x00 bytes. The payload is destroyed before it reaches the wire, so no amount of post-processing on the serialized form can recover it — the escaping has to happen inside the writer.

Enabling the option is glaze's documented remedy for exactly this (see its README, "escape control characters"); it is off by default there only because embedded nulls are hazardous for C APIs, which does not apply to a std::string wire field. Escaping is lossless in both directions, so any such byte round-trips unchanged rather than being replaced.

Applies to writing only. decode needs no counterpart: glaze's reader already accepts \\uXXXX and turns it back into the original byte.

Definition at line 401 of file wire.hpp.

Member Data Documentation

◆ escape_control_characters

bool morph::wire::detail::EscapingWriteOpts::escape_control_characters = true

Emit control bytes as \\uXXXX rather than raw.

Definition at line 404 of file wire.hpp.


The documentation for this struct was generated from the following file: