1 USING: help.markup help.syntax io.encodings strings ;
4 ARTICLE: "io.utf16" "Working with UTF16-encoded data"
5 "The UTF16 encoding is a variable-width encoding. Unicode code points are encoded as 2 or 4 byte sequences."
6 { $subsection encode-utf16le }
7 { $subsection encode-utf16be }
8 { $subsection decode-utf16le }
9 { $subsection decode-utf16be }
10 "Support for UTF16 data with a byte order mark:"
11 { $subsection encode-utf16 }
12 { $subsection decode-utf16 } ;
17 { $values { "seq" "a sequence of bytes" } { "str" string } }
18 { $description "Decodes a sequence of bytes representing a Unicode string in UTF16 format. The bytes must begin with a UTF16 byte order mark, which determines if the input is in little or big endian. To decode data without a byte order mark, use " { $link decode-utf16le } " or " { $link decode-utf16be } "." }
19 { $errors "Throws a " { $link decode-error } " if the input is malformed." } ;
22 { $values { "seq" "a sequence of bytes" } { "str" string } }
23 { $description "Decodes a sequence of bytes representing a Unicode string in big endian UTF16 format. The bytes must not begin with a UTF16 byte order mark. To decode data with a byte order mark, use " { $link decode-utf16 } "." }
24 { $errors "Throws a " { $link decode-error } " if the input is malformed." } ;
27 { $values { "seq" "a sequence of bytes" } { "str" string } }
28 { $description "Decodes a sequence of bytes representing a Unicode string in little endian UTF16 format. The bytes must not begin with a UTF16 byte order mark. To decode data with a byte order mark, use " { $link decode-utf16 } "." }
29 { $errors "Throws a " { $link decode-error } " if the input is malformed." } ;
31 { decode-utf16 decode-utf16le decode-utf16be } related-words
34 { $values { "str" string } { "seq" "a sequence of bytes" } }
35 { $description "Encodes a Unicode string as a sequence of bytes in big endian UTF16 format." } ;
38 { $values { "str" string } { "seq" "a sequence of bytes" } }
39 { $description "Encodes a Unicode string as a sequence of bytes in little endian UTF16 format." } ;
42 { $values { "str" string } { "seq" "a sequence of bytes" } }
43 { $description "Encodes a Unicode string as a sequence of bytes in UTF16 format with a byte order mark." } ;
45 { encode-utf16 encode-utf16be encode-utf16le } related-words