npm.io
2.2.0 • Published 2 weeks ago

@ifc-lite/encoding

Licence
MPL-2.0
Version
2.2.0
Deps
0
Size
91 kB
Vulns
0
Weekly
0
Stars
375

@ifc-lite/encoding

IFC string encoding and decoding, GlobalId (GUID) utilities, and property value parsing. Small, dependency-free helpers for the text-level details of IFC STEP files: the \X2\...\X0\ escape sequences used for non-ASCII characters, the 22-character base64-like IFC GUID format, and typed STEP property values like IFCBOOLEAN(.T.).

Install

npm install @ifc-lite/encoding

Usage

import {
  decodeIfcString,
  encodeIfcString,
  generateIfcGuid,
  ifcGuidToUuid,
  parsePropertyValue,
} from '@ifc-lite/encoding';

decodeIfcString('Gew\\X2\\00E4\\X0\\chshaus'); // 'Gewächshaus' (real umlaut)
encodeIfcString('Tür');                   // 'T\\X\\FCr'

const guid = generateIfcGuid();  // 22-char IFC GlobalId
const uuid = ifcGuidToUuid(guid); // standard UUID form

parsePropertyValue(['IFCBOOLEAN', '.T.']); // { displayValue: 'True', ifcType: ... }

Exports

  • decodeIfcString / encodeIfcString: STEP \X2\, \X\, \S\ escape handling
  • generateIfcGuid, generateUuid: new identifiers
  • uuidToIfcGuid, ifcGuidToUuid: convert between UUIDs and 22-char IFC GUIDs
  • isValidIfcGuid, isValidUuid: validation
  • parsePropertyValue: turn a parsed STEP property value (typed arrays, .T./.F., enums) into a display string plus optional IFC type name. It does not decode \X2\-style escapes: every ifc-lite parse path already decodes exactly once, at the parse boundary, and decoding a second time would collapse an authored \\ a second time. Pass a still-encoded literal through decodeIfcString first.

License

MPL-2.0

Keywords