escape_step_string

Function escape_step_string 

Source
pub fn escape_step_string(s: &str) -> String
Expand description

The STEP string-literal escaper; escape’s docs say why it is public. Escape a STEP string literal body: double the apostrophe and reverse solidus, and encode any character outside the basic graphic range as its \X2\/\X4\ control directive — never a raw byte — since ISO 10303-21 6.3.3.4 restricts a literal’s plain-text bytes to 32-126. buildingSMART’s IFC string-encoding guidance states the same for IFC2X3/IFC4/IFC4X3: a character outside decimal 32-126 “has to be encoded” (e.g. ‘Ä’ as \X2\00C4\X0\). A reader that treats the file’s bytes as ISO-8859-1 — the byte encoding the base standard and most real consumers assume — turns a raw UTF-8 multi-byte sequence into mojibake or a broken parse; this exact writer shape is a reported, reproduced defect in real IFC tooling (IfcOpenShell#699/#1016; files rejected by Solibri).

ASCII control characters (the C0 range plus DEL) take the same directive: a newline goes out as \X2\000A\X0\, which decode_ifc_string reads back as a newline, and the record stays on one line.

pub, and re-exported from the crate root as escape_step_string, so the integration-test binary tests/step_escape_parity.rs can pin it to the shared vectors in tests/fixtures/step_escape_vectors.json — the same vectors the TypeScript escapeStepString is held to, since the two implementations cannot share code (#3300). Only this one function is re-exported, not the whole module, so the rest of step_text stays crate-private and the public surface widens by exactly one symbol — narrower than the pub mod csv_cell the CSV parity pin already relies on.