Expand description
STEP string escape decoding (ISO 10303-21 / IFC).
Decoding only. The one writer is ifc_lite_export::escape_step_string
(a second, literal-unsafe encoder here was deleted: architecture review
behind #4577, F6). The round trip decode_ifc_string(escape(s)) == s is
pinned in rust/export/tests/step_escape_parity.rs.
IFC string attribute values encode non-ASCII characters with backslash
escape sequences. This module decodes them to native UTF-8 so the Rust
crates, CLI, and server surface the same text the browser parser does via
decodeIfcString in @ifc-lite/encoding. The two decoders are pinned to a
shared test-vector fixture (tests/fixtures/ifc_string_vectors.json).
Supported escapes:
\X2\HHHH..\X0\UTF-16 code units, 4 hex digits each (surrogate pairs ok)\X4\HHHHHHHH..\X0\Unicode scalar values, 8 hex digits each\X\HHsingle ISO-8859-1 byte (NOT code-page dependent: always the ISO 10646 row-0 value, per ISO 10303-21 6.4.3)\S\Cextended ASCII: code point ofCplus 128, mapped through the currently selected\P?\code page (default ISO 8859-1)\PA\..\PI\code-page directive (A=ISO 8859-1 .. I=ISO 8859-9): tracked for subsequent\S\escapes, then dropped. Any other letter is dropped without changing the active page.
ISO 10303-21 also doubles the reverse solidus inside a string literal, so
\\ decodes to one \. That arm sits AFTER the directive arms: a directive
immediately followed by an escaped backslash ends in three backslashes
(\X2\00FC\X0\ + \\), and collapsing pairs first would eat the
directive’s own terminator.
Unknown or malformed escapes are passed through unchanged. The ''
doubled-quote escape is NOT handled here — the tokenizer’s consumers strip
the surrounding quotes and un-double before calling this.
Functions§
- decode_
ifc_ string - Decode IFC STEP string escapes to UTF-8.
- is_
page_ quote_ operand - Whether the apostrophe at
pos, inside a STEP string literal, is the operand of the PAGE directive\S\(#7540). Tested before a doubled'':'5\S\''is “5§” and closes at its last quote. No other legal string unit ends in\S\right before an apostrophe, so this cannot misfire on a legal file. - step_
string_ literal_ end - Index just past the apostrophe closing the STEP string literal whose
opening apostrophe is at
open, orNonewhen it never closes (#7589).