Skip to main content

Module step_encoding

Module step_encoding 

Source
Expand description

STEP string escape decoding/encoding (ISO 10303-21 / IFC).

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\HH single ISO-8859-1 byte
  • \S\C extended ASCII: code point of C plus 128
  • \PC\ code-page directive, consumed and dropped

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.
encode_ifc_string
Encode a UTF-8 string back to IFC STEP escapes. Inverse of decode_ifc_string for the canonical (non-overlong) forms; kept for STEP writers and round-trip tests.