/core/alien/strings/strings-docs.factor

http://github.com/abeaumont/factor · Factor · 20 lines · 16 code · 4 blank · 0 comment · 0 complexity · 841c95008c71544b4d8a17419be43f16 MD5 · raw file

  1. USING: help.markup help.syntax strings byte-arrays alien libc
  2. debugger io.encodings.string sequences ;
  3. IN: alien.strings
  4. HELP: string>alien
  5. { $values { "string" string } { "encoding" "an encoding descriptor" } { "byte-array" byte-array } }
  6. { $description "Encodes a string together with a trailing null code point using the given encoding, and stores the resulting bytes in a freshly-allocated byte array." }
  7. { $errors "Throws an error if the string contains null characters, or characters not representable in the given encoding." } ;
  8. HELP: alien>string
  9. { $values { "c-ptr" c-ptr } { "encoding" "an encoding descriptor" } { "string/f" "a string or " { $link f } } }
  10. { $description "Reads a null-terminated C string from the specified address with the given encoding." } ;
  11. HELP: string>symbol
  12. { $values { "str/seq" { $or string sequence } } { "alien" alien } }
  13. { $description "Converts the string to a format which is a valid symbol name for the Factor VM's compiled code linker. By performing this conversion ahead of time, the image loader can run without allocating memory."
  14. $nl
  15. "On all platforms, symbols are ASCII strings." } ;
  16. ABOUT: "c-strings"