Module converter

Module converter 

Source
Expand description

Specification-oriented DCE 3.0a / 3.01a / 3.02a and CDCE converters.

Unlike the legacy modules (cdce, dce3_0a, dce3_01a, unicode), which are preserved to match old/libdce-2.51/ as closely as possible for comparison, this module implements DCE wire codecs from docs/ and delegates document conversion to shared APIs, with the limits documented below:

  • DCE 3.0a (3_0a, 3_0a_raw, hex_3_0a, hex_3_0a_raw): Raw transport encodes and decodes all mapped short Dcs in 0..=115 (MAX_DCE_3_0A_SHORT_DC, i.e. 0, 1, and 13..=115; short Dcs 2..=12 had no byte mappings in 3.0a and are logged as unmappable in FormatLog and omitted).
  • DCE 3.01a (3_01a, 3_01a_raw, hex_3_01a, hex_3_01a_raw): Raw transport encodes and decodes all allocated short Dcs in 0..=199 (MAX_DCE_3_01A_SHORT_DC), unlocking Base64 encapsulation (Dc 191 .. Dc 127..=190 / Dc 195 .. Dc 192) for arbitrary UTF-8 and data.
  • DCE 3.02a (3_02a, 3_02a_raw, hex_3_02a, hex_3_02a_raw): Stubbed (returns an error when invoked). Allocates short Dcs 0..=202 (MAX_DCE_3_02A_SHORT_DC), adding keyed embed framing (Dc 200..=202) on Core:C9..=CB, but the 18 October 2013 specification left its version selector in DCE_Version_Selectors and corresponding short Dc unassigned (marked as TBD; Dc 205 is DCE Version Selector 3.03a, so position 0x03 is not used here to avoid colliding with 3.03a).
  • Corrected Base64 digit 34 (Dc 161, 'i') vs digit 8 (Dc 135, 'I'): The upstream .ods spreadsheet auto-capitalized lowercase 'i' to 'I', corrupting Base64_to_Dc and Dc_to_Base64.
  • Corrected Dc 113 (End DCE content) mapping (Core:03): The upstream DCE Character List by ID sheet had a typo Core:01 instead of Core:03.
  • Unicode conversion uses the shared modern equivalence and approximation resolver, including NEXT LINE for the historical newline character. Unmapped Unicode is preserved using UTF-8 encapsulation on capable targets.

The 3.02a version selector is left marked as TBD because its spreadsheet leaves the selector unassigned and Dc 205 is allocated to DCE 3.03a. Explicit legacy one-step and legacy HTML translators retain PHP-compatible behavior. Normal HTML escapes shared Unicode text. See porting-notes.md for audit limits.

Enums§

DceVersion
DCE specification version.

Constants§

MAX_DCE_3_0A_SHORT_DC
Maximum short Dc allocated in DCE 3.0a (0..=115).
MAX_DCE_3_01A_SHORT_DC
Maximum short Dc allocated in DCE 3.01a (0..=199).
MAX_DCE_3_02A_SHORT_DC
Maximum short Dc allocated in DCE 3.02a (0..=202).

Functions§

base64_char_to_short_dc
Maps a standard Base64 ASCII byte (A-Z, a-z, 0-9, +, /, =) to its DCE 3.01a+ short Dc (127..=190, 195).
dce_convert
Converts between any dceutils / DCE / CDCE formats using the spec-compliant implementations (supporting DCE 3.0a 0..=115, DCE 3.01a 0..=199 with Base64 encapsulation, DCE 3.02a 0..=202, and general/legacy CDCE).
dce_convert_with_log
Converts between any dceutils / DCE / CDCE formats using the spec-compliant implementations, returning the converted bytes and FormatLog.
dce_convert_with_options
Converts formats with optional replacement-character recovery for damaged text, returning converted bytes and diagnostics.
decode_dc64_to_bytes
Decodes a slice of DCE 3.01a+ Base64 short Dcs (127..=190, 195) into raw bytes.
decode_dce_preserving_controls
Decodes a DCE binary or hex-encoded stream (dce, 3_0a, 3_0a_raw, 3_01a, 3_01a_raw, 3_02a, 3_02a_raw, and their hex_* variants) into a sequence of short Dc IDs while preserving all stateful DCE control characters (13..=16, 112..=115, 194, 196..=199, 205) as-is.
decode_dce_preserving_controls_with_options
Decodes DCE while retaining encoding controls and diagnosing recovery.
encode_bytes_to_dc64
Encodes arbitrary bytes into DCE 3.01a+ Base64 short Dcs (127..=190, 195).
encode_dce_preserving_controls
Encodes a sequence of short Dc IDs into a DCE binary or hex-encoded format (dce, 3_0a, 3_0a_raw, 3_01a, 3_01a_raw, 3_02a, 3_02a_raw, and their hex_* variants), respecting any explicit DCE sheet/control Dcs already present in dcs and automatically inserting sheet transitions or framing when absent.
encode_utf8_to_dc64_encapsulated
Encodes UTF-8 bytes into a DCE 3.01a+ Base64-encapsulated short Dc sequence (Dc 191, Base64 Dcs 127..=190 / 195, Dc 192).
get_dce_version
Detects the DCE format version ("3_0a" or "3_01a") of data.
get_dce_version_with_log
Detects the DCE format version ("3_0a" or "3_01a") of data, recording any errors in log.
is_base64_payload_short_dc
Returns true if short_dc is a Base64 digit (127..=190) or padding (195).
is_dce_encoding_control_dc
Returns true if short_dc is a DCE stateful-encoding control character or unbounded-content framing marker that has no glyph representation in text/CDCE.
select_dce_version_for_short_dcs
Selects the minimum implemented DceVersion (V3_0a or V3_01a) required to represent dcs.
short_dc_to_base64_char
Maps a DCE 3.01a+ Base64 short Dc (127..=190, 195) to its standard Base64 character.
unicode_codepoint_to_short_dc
Selects a DCE short character with an exact shared Unicode equivalence.