~ chicken-core (master) /manual/Module (chicken bytevector)


  1[[tags: manual]]
  2[[toc:]]
  3
  4== Module (chicken bytevector)
  5
  6This module contains procedures for dealing with "bytevectors",
  7fixed-size sequences of unsigned 8-bit integers.
  8
  9=== bytevector
 10
 11<procedure>(bytevector FIXNUM ...)</procedure>
 12
 13Returns a new bytevector containing the values {{FIXNUM ...}}.
 14
 15=== make-bytevector
 16
 17<procedure>(make-bytevector SIZE)</procedure>
 18
 19Returns a bytevector object of {{SIZE}} bytes, aligned on an 8-byte boundary,
 20uninitialized.
 21
 22=== bytevector?
 23
 24<procedure>(bytevector? X)</procedure>
 25
 26Returns {{#t}} if {{X}} is a bytevector object, or
 27{{#f}} otherwise.
 28
 29=== bytevector-length
 30
 31<procedure>(bytevector-length BYTEVECTOR)</procedure>
 32
 33Returns the number of bytes in {{BYTEVECTOR}}.
 34
 35=== bytevector-u8-ref
 36
 37<procedure>(bytevector-u8-ref BYTEVECTOR INDEX)</procedure>
 38
 39Returns the byte at {{INDEX}} in {{BYTEVECTOR}}.
 40
 41=== bytevector-u8-set!
 42
 43<procedure>(bytevector-u8-set! BYTEVECTOR INDEX VALUE)</procedure>
 44
 45Destructively modifies the byte at {{INDEX}} in {{BYTEVECTOR}} to {{VALUE}}, which
 46should be a fixnum.
 47
 48=== utf8->string
 49
 50<procedure>(utf8->string BYTEVECTOR [START END])</procedure>
 51
 52Returns a string with the contents of {{BYTEVECTOR}}. Invalid encodings
 53for characters signal an error.
 54
 55<procedure>(bytes->string BYTEVECTOR [START END])</procedure>
 56
 57Similar to {{utf8->string}}, but accepts any byte sequence without
 58validating the contents. Byte-sequences that are not representing
 59valid UTF-8 characters are retained and, if extracted with {{string-ref}}
 60are converted to a trailing surrogate pair half in the range U+DC80 to U+DCFF.
 61
 62=== string->utf8
 63
 64<procedure>(string->utf8 STRING)</procedure>
 65
 66Returns a bytevector with the contents of {{STRING}}.
 67
 68=== latin1->string
 69
 70<procedure>(latin1->string BYTEVECTOR)</procedure>
 71
 72Returns a string with the contents of {{BYTEVECTOR}} converted from Latin-1 (ISO-8859-1) encoding to UTF-8.
 73
 74=== string->latin1
 75
 76<procedure>(string->latin1 STRING)</procedure>
 77
 78Returns a bytevector with the contents of {{STRING}} encoded as Latin-1 (ISO-?8859-1).
 79
 80=== bytevector=?
 81
 82<procedure>(bytevector=? BYTEVECTOR1 BYTEVECTOR2)</procedure>
 83
 84Returns {{#t}} if the two argument bytevectors are of the same
 85size and have the same content.
 86
 87=== bytevector-append
 88
 89<procedure>(bytevector-append BYTEVECTOR ...)</procedure>
 90
 91Returns a new bytevector holding the concatenated contents of all
 92argument bytevectors.
 93
 94=== bytevector-copy
 95
 96<procedure>(bytevector-copy BYTEVECTOR #!optional START END)</procedure>
 97
 98Returns a new bytevector holding the contents of {{BYTEVECTOR}} between
 99the indices {{START}} to {{END}}.
100
101=== bytevector-copy!
102
103<procedure>(bytevector-copy! TO AT FROM #!optional START END)</procedure>
104
105Copioes the contents of the bytevector FROM between
106the indices {{START}} to {{END}} into the bytevector {{TO}}, starting at
107index {{AT}}.
108
109
110---
111Previous: [[Module (chicken bitwise)]]
112
113Next: [[Module (chicken condition)]]
114
115
Trap