~ chicken-core (master) /manual/Module (chicken bytevector)
Trap1[[tags: manual]]2[[toc:]]34== Module (chicken bytevector)56This module contains procedures for dealing with "bytevectors",7fixed-size sequences of unsigned 8-bit integers. Note that they are8indistinguishable from srfi-4 u8vectors and can be used9interchangeably. The R7RS literal expressions {{#u8(64 65 ...)}} can10also be used for construction. See [[Module (chicken number-vector)]].1112=== bytevector1314<procedure>(bytevector FIXNUM ...)</procedure>1516Returns a new bytevector containing the values {{FIXNUM ...}}.1718=== make-bytevector1920<procedure>(make-bytevector SIZE)</procedure>2122Returns a bytevector object of {{SIZE}} bytes, aligned on an 8-byte boundary,23uninitialized.2425=== bytevector?2627<procedure>(bytevector? X)</procedure>2829Returns {{#t}} if {{X}} is a bytevector object, or30{{#f}} otherwise.3132=== bytevector-length3334<procedure>(bytevector-length BYTEVECTOR)</procedure>3536Returns the number of bytes in {{BYTEVECTOR}}.3738=== bytevector-u8-ref3940<procedure>(bytevector-u8-ref BYTEVECTOR INDEX)</procedure>4142Returns the byte at {{INDEX}} in {{BYTEVECTOR}}.4344=== bytevector-u8-set!4546<procedure>(bytevector-u8-set! BYTEVECTOR INDEX VALUE)</procedure>4748Destructively modifies the byte at {{INDEX}} in {{BYTEVECTOR}} to {{VALUE}}, which49should be a fixnum.5051=== utf8->string5253<procedure>(utf8->string BYTEVECTOR [START END])</procedure>5455Returns a string with the contents of {{BYTEVECTOR}}. Invalid encodings56for characters signal an error.5758<procedure>(bytes->string BYTEVECTOR [START END])</procedure>5960Similar to {{utf8->string}}, but accepts any byte sequence without61validating the contents. Byte-sequences that are not representing62valid UTF-8 characters are retained and, if extracted with {{string-ref}}63are converted to a trailing surrogate pair half in the range U+DC80 to U+DCFF.6465=== string->utf86667<procedure>(string->utf8 STRING)</procedure>6869Returns a bytevector with the contents of {{STRING}}.7071=== latin1->string7273<procedure>(latin1->string BYTEVECTOR)</procedure>7475Returns a string with the contents of {{BYTEVECTOR}} converted from Latin-1 (ISO-8859-1) encoding to UTF-8.7677=== string->latin17879<procedure>(string->latin1 STRING)</procedure>8081Returns a bytevector with the contents of {{STRING}} encoded as Latin-1 (ISO-?8859-1).8283=== bytevector=?8485<procedure>(bytevector=? BYTEVECTOR1 BYTEVECTOR2)</procedure>8687Returns {{#t}} if the two argument bytevectors are of the same88size and have the same content.8990=== bytevector-append9192<procedure>(bytevector-append BYTEVECTOR ...)</procedure>9394Returns a new bytevector holding the concatenated contents of all95argument bytevectors.9697=== bytevector-copy9899<procedure>(bytevector-copy BYTEVECTOR #!optional START END)</procedure>100101Returns a new bytevector holding the contents of {{BYTEVECTOR}} between102the indices {{START}} to {{END}}.103104=== bytevector-copy!105106<procedure>(bytevector-copy! TO AT FROM #!optional START END)</procedure>107108Copioes the contents of the bytevector FROM between109the indices {{START}} to {{END}} into the bytevector {{TO}}, starting at110index {{AT}}.111112113---114Previous: [[Module (chicken bitwise)]]115116Next: [[Module (chicken condition)]]117118