ws-cleanup: codecs/compress/PackBits; UTF-16 and half floats from one place

- codecs/compress/PackBits (new, from image/tiff/Pixels): decode (lenient count + a clean flag for strict callers)
  and encode; image/tiff and layered/psd (which carried its own decoder) use it. tests/codecs/packbits.
- codecs/text/Text.utf16(buf, offset, length, bigEndian?): the UTF-16 -> UTF-8 conversion codecs/font/TrueType,
  archive/7z and layered/psd each wrote (lone surrogates -> U+FFFD everywhere now).
- image/tiff/Pixels and data/cbor use core/Bytes.half instead of their own float16 decoders.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
4DBugandClaude Opus 5.5 committed 2026-10-31 12:28:33 -05:00
1 parent 434a304315
commit 9bcf061338
13 files changed
+191 -178

No files matched your search

+2 -15
View File
@@ -3,6 +3,7 @@
-- streams info (pack info, folders with their coders and bind pairs, substreams), files info (names, empty streams /
-- files, anti items, times, attributes). Not --!native: a parse failure raises an Err value that parse() catches and
-- returns; any other error is a bug and propagates (the tests' fuzz pass sees it).
local Text = require("@formats/codecs/text/Text")
local Err = require("@formats/core/Err")
local Bytes = require("@formats/core/Bytes")
@@ -395,21 +396,7 @@ local function streamsInfo(r: Bytes.Reader): Streams
end
local function utf16(b: buffer, o: number, n: number): string
local out = {}
local i = 0
while i + 1 < n do
local u = buffer.readu16(b, o + i)
i += 2
if u >= 0xD800 and u < 0xDC00 and i + 1 < n then
local lo = buffer.readu16(b, o + i)
if lo >= 0xDC00 and lo < 0xE000 then
u = 0x10000 + (u - 0xD800) * 1024 + (lo - 0xDC00)
i += 2
end
end
table.insert(out, utf8.char(u))
end
return table.concat(out)
return Text.utf16(b, o, n, false)
end
local function filesInfo(r: Bytes.Reader): { File }
+1 -1
View File
@@ -26,7 +26,7 @@ local SevenZip = {
category = "archive",
extensions = { "7z" },
mime = { "application/x-7z-compressed" },
deps = { "core/Err", "core/Bytes", "core/Crc32", "Types", "codecs/compress/Lzma", "codecs/compress/Deflate", "codecs/compress/Bzip2", "codecs/compress/Zstd", "containers/Archive" },
deps = { "core/Err", "core/Bytes", "core/Crc32", "Types", "codecs/compress/Lzma", "codecs/compress/Deflate", "codecs/compress/Bzip2", "codecs/compress/Zstd", "containers/Archive", "codecs/text/Text" },
caps = { decode = true, encode = false, methods = { "copy", "lzma", "lzma2", "deflate", "bcj", "delta" }, encrypted = false },
}