constructor
ffi.CStringConstructor.constructor
constructor CStringConstructor(
byteOffset?: number,
byteLength?: number
): string;
Read a UTF-8 encoded C string into a JavaScript string.
If byteLength is not provided, the string is assumed to be null-terminated. The result is a clone of the C string, so it is safe to keep using it after the memory at ptr has been freed. A falsy ptr yields an empty string.
Bun catches some invalid pointers, but not all. Passing an invalid pointer, or reading past the end of the memory it points to, can crash the program or cause undefined behavior.
@param ptr
The pointer to the C string
@param byteOffset
bytes to skip before reading
@param byteLength
bytes to read
var ptr = lib.symbols.getVersion();
console.log(new CString(ptr));Referenced types
type Pointer = number & { __pointer__: null }