Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
从原始指针读取 C 字符串
CString
const char*
import { dlopen, FFIType, CString } from 'arkffi'; const lib = dlopen('libffi_target.so', { getVersion: { args: [], returns: FFIType.int64 }, }); const ptr: number = lib.symbols.getVersion(); const cstr = new CString(ptr); cstr.toString(); // → "1.0.0" cstr.length; // → 5 lib.close();
constructor(ptr: number, byteOffset?: number, byteLength?: number);
ptr
number
byteOffset
0
byteLength
const cstr = new CString(ptr, 0, 5); cstr.toString(); // 读取前 5 个字节
length
get length(): number;
toString()
toString(): string;
const cstr = new CString(0); cstr.toString(); // → "" cstr.length; // → 0
此页面对您有帮助吗?