]> gitweb.factorcode.org Git - factor.git/blob - basis/io/encodings/string/string-docs.factor
Switch to https urls
[factor.git] / basis / io / encodings / string / string-docs.factor
1 ! Copyright (C) 2008,2011 Daniel Ehrenberg, Doug Coleman.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: byte-arrays help.markup help.syntax io.encodings.string
4 strings ;
5 IN: io.encodings.string
6
7 ARTICLE: "io.encodings.string" "Encoding and decoding strings"
8 "Strings can be encoded or decoded to and from byte arrays through an encoding by passing "
9 { $link "encodings-descriptors" } " to the following words:"
10 { $subsections
11     encode
12     decode
13 } ;
14
15 HELP: decode
16 { $values { "byte-array" byte-array } { "encoding" "an encoding descriptor" }
17     { "string" string } }
18 { $description "Converts an array of bytes to a string, interpreting that array of bytes as a string with the given encoding." }
19 { $examples
20     { $example "USING: io.encodings.string io.encodings.utf8 prettyprint ;
21 B{ 230 136 145 231 136 177 228 189 160 } utf8 decode ."
22 "\"我爱你\""
23     }
24 } ;
25
26 HELP: encode
27 { $values { "string" string } { "encoding" "an encoding descriptor" } { "byte-array" byte-array } }
28 { $description "Converts a string into a byte array, interpreting that string with the given encoding." }
29 { $examples
30     { $example "USING: io.encodings.string io.encodings.utf8 prettyprint ;
31 \"我爱你\" utf8 encode ."
32 "B{ 230 136 145 231 136 177 228 189 160 }"
33     }
34 } ;