Skip to content
FutureBlitz

    Install

    Import std.ffi.cstring

    CString

    std.ffi.cstring

    extend

    Extend CString

    What a CString does besides ToString: a copy of a String that C code can keep, its length, and giving the copy back.

    std/ffi/cstring.fb, line 15

    • Public Static Method From(text: String): CString static method #

      A CString of text's UTF-8 bytes and a NUL, in memory of its own, which C code can keep until Free gives it back. C reads it up to its first NUL, so a NUL in text ends it there.

      Examples

      Local copy = CString.From("hello")
      Unsafe
          Expect(copy.Length() == 5)
          copy.Free()
      End Unsafe
    • @PanicsAtCaller Public Unsafe Method Length(): Int64 method #

      How many bytes it has before its first NUL. Panics when it's Null.

    • @PanicsAtCaller Public Unsafe Method Free() method #

      Gives back what From made, and nothing else, which panics. Null is nothing to give back.

    Report an issue with this page or with FutureBlitz on GitHub.