mirror of
https://github.com/morluto/rea
synced 2026-10-26 06:16:17 -04:00
b5ededd0f9
Parse otool field occurrences once and reject valueless required fields while retaining empty dylib options. Preserve compiler exit outcomes and stderr through capture errors and nested Ghidra causes, with explicit UTF-8 truncation after redaction. Strengthen provider failure assertions and document the manual Ghidra 12.1.4 macOS x64 decompiler build using upstream instructions. Validation: focused producer tests, nine fake-compiler preparation and cancellation tests, temporary-directory hygiene, static and documentation checks. No real Swift or Ghidra compilation was run locally.
17 lines
564 B
TypeScript
17 lines
564 B
TypeScript
/** Keep a UTF-8 string within a byte budget without cutting a code point. */
|
|
export const boundedUtf8Text = (
|
|
value: string,
|
|
maximumBytes: number,
|
|
): { readonly text: string; readonly truncated: boolean } => {
|
|
let bytes = 0;
|
|
let end = 0;
|
|
for (const codePoint of value) {
|
|
const codePointBytes = Buffer.byteLength(codePoint, "utf8");
|
|
if (bytes + codePointBytes > maximumBytes)
|
|
return { text: value.slice(0, end), truncated: true };
|
|
bytes += codePointBytes;
|
|
end += codePoint.length;
|
|
}
|
|
return { text: value, truncated: false };
|
|
};
|