Skip to main content

Read APL+Win component files (.sf) from Python

Project description

aplwin-sf

CI PyPI version

Read APL+Win component files (.sf) from Python.

APL+Win stores source code and data in a proprietary binary format called "component files" (file extension .sf). This library parses them and decodes APL+Win's character encoding to Unicode, producing readable UTF-8 text.

Installation

pip install aplwin-sf

Quick start

Python API

from aplwin_sf import read_functions

for fn in read_functions("myfuncs.sf"):
    print(fn.name, len(fn.text), "chars")
from aplwin_sf import decode

raw = b"\x95IO\x061"
print(decode(raw))  # ⎕IO←1

Command line

# Print all functions to stdout
aplwin-sf myfuncs.sf

# Extract a directory of .sf files to .apl text files
aplwin-sf /path/to/sf/files/ -o apl_source/

What it does

  1. Parses the binary .sf format — scans for function-text sub-objects by looking for the (del) marker that begins every APL function definition.

  2. Decodes APL+Win's character encoding — a single-byte encoding based on Code Page 437 with APL symbol overlays. Maps bytes like 0x95, 0x06, 0xE2, etc.

  3. Extracts function metadata — parses function names from headers, handling niladic, monadic, and dyadic forms.

API

read_functions(source) → list[Function]

Extract all APL functions from a .sf file.

  • source — a file path (str or Path) or raw bytes
  • Returns a list of Function(name, text, offset, raw) objects

read_file(source) → ComponentFile

Read a .sf file and return a ComponentFile(path, functions, size).

decode(data: bytes) → str

Decode APL+Win encoded bytes to a Unicode string.

APL_MAP: dict[int, str]

The complete byte → Unicode character mapping table.

Background

APL+Win is a commercial APL implementation for Windows, originally by Manugistics (now APL2000/Cognizant). It stores APL objects — functions, variables, arrays — in "component files" with the .sf extension.

These files use a proprietary binary format with no public documentation. This library was developed by reverse-engineering the format from real .sf files, with the character encoding cross-referenced against the ∆AV table from Dyalog's aplwincfs project.

Character encoding notes

APL+Win's file encoding is not the same as the ⎕AV (atomic vector) mapping. The ⎕AV maps logical character positions; the file encoding maps raw byte values from the APL+Win font/codepage. For example:

Byte File encoding Dyalog ∆AV
0x86 (rho)
0x8D (drop)
0x8F × (times)
0xE8 (floor)
0xFD (ceiling) ¯

The file encoding in this library was validated against actual APL source code in context (e.g., 10× must be "ten times", not "ten floor").

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aplwin_sf-0.1.1.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aplwin_sf-0.1.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file aplwin_sf-0.1.1.tar.gz.

File metadata

  • Download URL: aplwin_sf-0.1.1.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aplwin_sf-0.1.1.tar.gz
Algorithm Hash digest
SHA256 97b3bee6a7151fedef65290b695255f4cd4c5e41c49b310a65c4e49cdad52b8a
MD5 4288edbeb6bf61006e543fb1e7ff9280
BLAKE2b-256 137cf0b1c9f69179ba111e474fd0b02f96404632b56607f14a190dd91695053d

See more details on using hashes here.

Provenance

The following attestation bundles were made for aplwin_sf-0.1.1.tar.gz:

Publisher: ci.yml on andyreagan/aplwin-sf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aplwin_sf-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: aplwin_sf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aplwin_sf-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f5f1e9e8bf06c8e02b02ef68d662db2e05dc5b4f3552e3f0e2d2f0879e340021
MD5 d290ef08803b795371d0409e8f7dc034
BLAKE2b-256 2e3a0f18b35dfe5e2eaefa2e885e452381ee6e247c33bbb5f4807b54766641ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for aplwin_sf-0.1.1-py3-none-any.whl:

Publisher: ci.yml on andyreagan/aplwin-sf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page