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
這個頁面有幫助嗎?