Read APL+Win component files (.sf) from Python
Project description
aplwin-sf
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
-
Parses the binary
.sfformat — scans for function-text sub-objects by looking for the∇(del) marker that begins every APL function definition. -
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. -
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 (strorPath) or rawbytes- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97b3bee6a7151fedef65290b695255f4cd4c5e41c49b310a65c4e49cdad52b8a
|
|
| MD5 |
4288edbeb6bf61006e543fb1e7ff9280
|
|
| BLAKE2b-256 |
137cf0b1c9f69179ba111e474fd0b02f96404632b56607f14a190dd91695053d
|
Provenance
The following attestation bundles were made for aplwin_sf-0.1.1.tar.gz:
Publisher:
ci.yml on andyreagan/aplwin-sf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aplwin_sf-0.1.1.tar.gz -
Subject digest:
97b3bee6a7151fedef65290b695255f4cd4c5e41c49b310a65c4e49cdad52b8a - Sigstore transparency entry: 1097415060
- Sigstore integration time:
-
Permalink:
andyreagan/aplwin-sf@b900c05dd391824bbf9859614890a67ca96d9bd7 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/andyreagan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@b900c05dd391824bbf9859614890a67ca96d9bd7 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5f1e9e8bf06c8e02b02ef68d662db2e05dc5b4f3552e3f0e2d2f0879e340021
|
|
| MD5 |
d290ef08803b795371d0409e8f7dc034
|
|
| BLAKE2b-256 |
2e3a0f18b35dfe5e2eaefa2e885e452381ee6e247c33bbb5f4807b54766641ea
|
Provenance
The following attestation bundles were made for aplwin_sf-0.1.1-py3-none-any.whl:
Publisher:
ci.yml on andyreagan/aplwin-sf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aplwin_sf-0.1.1-py3-none-any.whl -
Subject digest:
f5f1e9e8bf06c8e02b02ef68d662db2e05dc5b4f3552e3f0e2d2f0879e340021 - Sigstore transparency entry: 1097415061
- Sigstore integration time:
-
Permalink:
andyreagan/aplwin-sf@b900c05dd391824bbf9859614890a67ca96d9bd7 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/andyreagan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@b900c05dd391824bbf9859614890a67ca96d9bd7 -
Trigger Event:
push
-
Statement type: