1 ! Copyright (C) 2008,2011 Daniel Ehrenberg, Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: byte-arrays help.markup help.syntax io.encodings.string
5 IN: io.encodings.string
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:"
16 { $values { "byte-array" byte-array } { "encoding" "an encoding descriptor" }
18 { $description "Converts an array of bytes to a string, interpreting that array of bytes as a string with the given encoding." }
20 { $example """USING: io.encodings.string io.encodings.utf8 prettyprint ;
21 B{ 230 136 145 231 136 177 228 189 160 } utf8 decode ."""
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." }
30 { $example """USING: io.encodings.string io.encodings.utf8 prettyprint ;
31 "我爱你" utf8 encode ."""
32 "B{ 230 136 145 231 136 177 228 189 160 }"