node-ctypes - v2.17.1
    Preparing search index...

    Function create_string_buffer

    • Create a C string buffer (null-terminated).

      Python equivalent: ctypes.create_string_buffer

      Parameters

      • init: string | number | Uint8Array<ArrayBufferLike>

        Size in bytes, a string to copy, or an existing Buffer

      • Optionalsize: number

      Returns Buffer<ArrayBufferLike> & CharBufferValue

      A Buffer containing the null-terminated string

      const buf = create_string_buffer('Hello');
      console.log(string_at(buf)); // "Hello"

      const buf2 = create_string_buffer(256); // 256-byte zero-filled buffer

      As in CPython, size null is the computed size and is ignored for an integer init; a negative size throws RangeError `Array length must be

      = 0, not N, a non-integer size TypeError can't multiply sequence by non-int of type 'float'`.