示例工程 11-formatting-and-bytes
11-formatting-and-bytes/03-pack-header/README.md
# 03 · pack-header
**演示**:`>I2B` 按大端写 2 字节魔数 + 1 字节版本,再 `unpack` 读回。
**运行时**:`lua54`(LuaJIT 没有 `string.pack`)。
**运行**:
```sh
.tools/bin/lua54 scripts/run-example.lua examples/11-formatting-and-bytes/03-pack-header
.tools/bin/lua54 scripts/test-example.lua examples/11-formatting-and-bytes/03-pack-header
```
**预期输出**(lua 5.4.9 / macOS arm64):
```text
packed=4c4603
magic=0x4c46 version=3
```
**看点**:格式串 `>` 大端、`I2` 2 字节整数、`B` 1 字节。
**注意**:`I2`/`I4` 的宽度由格式串决定,跨语言要对齐。