string
Factor handbook » The language » Collections » Strings

Next:string? ( object -- ? )


Vocabulary
strings

Class description
The class of fixed-length character strings. See Character and string syntax for syntax and Strings for general information.

Definition


Methods

















































M: string >post-data
utf8 encode
"application/octet-stream" <post-data> swap >>data ;











































































































































































M: string item>xml
1 nenum T{ xml-chunk
{ seq
V{
""
T{ tag { name ~name~ } { children ~vector~ } }
""
}
}
} interpolate-xml ;
















































M: string make-slot-descriptions
[
swap [ dup number>string ] dip dup dup printable?
[ 1string ] [
dup 255 <= [
H{
{ 0 "\\0" }
{ 7 "\\a" }
{ 8 "\\b" }
{ 9 "\\t" }
{ 10 "\\n" }
{ 27 "\\e" }
{ 12 "\\f" }
{ 13 "\\r" }
{ 11 "\\v" }
} ?at [ "\\x%02x" sprintf ] unless
] [ "\\u{%x}" sprintf ] if
] if slot-description boa
] { } map-index-as ;



M: string metar
"https://tgftp.nws.noaa.gov/data/observations/metar/stations/%..."
sprintf http-get nip ;















































































































M:: string split-lines ( seq -- seq' )
seq length :> len V{ } clone 0
[ dup len < ] [
dup seq [ linebreak? ] find-from
[ len or [ seq subseq-unsafe suffix! ] [ 1 + ] bi ]
[ 13 eq? [ dup seq ?nth 10 eq? [ 1 + ] when ] when ] bi*
] while drop { } like ; inline















M: string taf
"https://tgftp.nws.noaa.gov/data/forecasts/taf/stations/%s.TXT"
sprintf http-get nip ;