]> gitweb.factorcode.org Git - factor.git/blob - core/strings/strings-docs.factor
docs: replace $description with $class-description for class words
[factor.git] / core / strings / strings-docs.factor
1 USING: arrays byte-arrays help.markup help.syntax
2 kernel kernel.private strings.private sequences vectors
3 sbufs math help.vocabs ;
4 IN: strings
5
6 ARTICLE: "strings" "Strings"
7 "The " { $vocab-link "strings" } " vocabulary implements a data type for storing text. Strings are represented as fixed-size mutable sequences of Unicode code points. Code points are represented as integers in the range [0,2,097,152]."
8 $nl
9 "Strings implement the " { $link "sequence-protocol" } ", and basic string manipulation can be performed with " { $link "sequences" } " from the " { $vocab-link "sequences" } " vocabulary. More text processing functionality can be found in vocabularies carrying the " { $link T{ vocab-tag { name "text" } } } " tag."
10 $nl
11 "Strings form a class:"
12 { $subsections
13     string
14     string?
15 }
16 "Creating new strings:"
17 { $subsections
18     >string
19     <string>
20 }
21 "Creating a string from a single character:"
22 { $subsections 1string }
23 "Resizing strings:"
24 { $subsections resize-string }
25 { $see-also "syntax-strings" "sbufs" "unicode" "io.encodings" } ;
26
27 ABOUT: "strings"
28
29 HELP: string
30 { $class-description "The class of fixed-length character strings. See " { $link "syntax-strings" } " for syntax and " { $link "strings" } " for general information." } ;
31
32 HELP: string-nth
33 { $values { "n" fixnum } { "string" string } { "ch" "the character at the " { $snippet "n" } "th index" } }
34 { $description "Unsafe string accessor, used to define " { $link nth } " on strings." }
35 { $warning "This word is in the " { $vocab-link "strings.private" } " vocabulary because it does not perform type or bounds checking. User code should call " { $link nth } " instead." } ;
36
37 HELP: set-string-nth
38 { $values { "ch" "a character" } { "n" fixnum } { "string" string }  }
39 { $description "Unsafe string mutator, used to define " { $link set-nth } " on strings." }
40 { $warning "This word is in the " { $vocab-link "strings.private" } " vocabulary because it does not perform type or bounds checking. User code should call " { $link set-nth } " instead." } ;
41
42 HELP: <string>
43 { $values { "n" "a positive integer specifying string length" } { "ch" "an initial character" } { "string" string } }
44 { $description "Creates a new string with the given length and all characters initially set to " { $snippet "ch" } "." } ;
45
46 HELP: 1string
47 { $values { "ch" "a character" } { "str" string } }
48 { $description "Outputs a string of one character." } ;
49
50 HELP: >string
51 { $values { "seq" { $sequence "characters" } } { "str" string } }
52 { $description "Outputs a freshly-allocated string with the same elements as a given sequence, by interpreting the sequence elements as Unicode code points." }
53 { $notes "This operation is only appropriate if the underlying sequence holds Unicode code points, which is rare unless it is a " { $link slice } " of another string. To convert a sequence of bytes to a string, use the words documented in " { $link "io.encodings.string" } "." }
54 { $errors "Throws an error if the sequence contains elements other than integers." } ;
55
56 HELP: resize-string
57 { $values { "n" "a non-negative integer" } { "str" string } { "newstr" string } }
58 { $description "Resizes the string to have a length of " { $snippet "n" } " elements. When making the string shorter, this word may either create a new string or modify the existing string in place. When making the string longer, this word always allocates a new string, filling remaining space with zeroes." }
59 { $side-effects "str" } ;