Next: , Previous: , Up: iklib bytevectors   [Index]


6.26.3 Converting bytevectors

These conversion functions work like bytevector->u8-list and u8-list->bytevector. The following bindings are exported by the library (vicare).

Function: utf8->string-length bv
Function: utf8->string-length bv handling-mode

Given a bytevector representing a string in UTF-8 encoding: compute and return the length of the Scheme string required to hold the characters.

The optional handling-mode must be an error handling mode as validated by the standard syntax error-handling-mode; when not given: it defaults to ‘raise’. This argument has the same meaning it has for utf8->string (see utf8->string).

Function: utf16->string-length bytevector endianness
Function: utf16->string-length bytevector endianness endianness-mandatory
Function: utf16->string-length bytevector endianness endianness-mandatory handling-mode

Given a bytevector representing a string in UTF-16 encoding: compute the length of the Scheme string required to hold the characters and return it as non–negative fixnum.

All the arguments have the same meaning they have for utf16->string (see utf16->string).

Function: utf32->string-length bytevector endianness
Function: utf32->string-length bytevector endianness endianness-mandatory
Function: utf32->string-length bytevector endianness endianness-mandatory handling-mode

Given a bytevector representing a string in UTF-32 encoding: compute the length of the Scheme string required to hold the characters and return it as non–negative fixnum.

All the arguments have the same meaning they have for utf32->string (see utf32->string).

Function: bytevector->s8-list bytevector
Function: s8-list->bytevector list

Convert between a list of signed bytes and a bytevector.

Function: s16l-list->bytevector list
Function: s16b-list->bytevector list
Function: s16n-list->bytevector list
Function: u16l-list->bytevector list
Function: u16b-list->bytevector list
Function: u16n-list->bytevector list
Function: bytevector->s16l-list bytevector
Function: bytevector->s16b-list bytevector
Function: bytevector->s16n-list bytevector
Function: bytevector->u16l-list bytevector
Function: bytevector->u16b-list bytevector
Function: bytevector->u16n-list bytevector

Convert between a list of signed or unsigned 16-bit words and a bytevector in which the words are stored in little, big or native endianness.

Function: s32l-list->bytevector list
Function: s32b-list->bytevector list
Function: s32n-list->bytevector list
Function: u32l-list->bytevector list
Function: u32b-list->bytevector list
Function: u32n-list->bytevector list
Function: bytevector->s32l-list bytevector
Function: bytevector->s32b-list bytevector
Function: bytevector->s32n-list bytevector
Function: bytevector->u32l-list bytevector
Function: bytevector->u32b-list bytevector
Function: bytevector->u32n-list bytevector

Convert between a list of signed or unsigned 32-bit words and a bytevector in which the words are stored in little, big or native endianness.

Function: s64l-list->bytevector list
Function: s64b-list->bytevector list
Function: s64n-list->bytevector list
Function: u64l-list->bytevector list
Function: u64b-list->bytevector list
Function: u64n-list->bytevector list
Function: bytevector->s64l-list bytevector
Function: bytevector->s64b-list bytevector
Function: bytevector->s64n-list bytevector
Function: bytevector->u64l-list bytevector
Function: bytevector->u64b-list bytevector
Function: bytevector->u64n-list bytevector

Convert between a list of signed or unsigned 64-bit words and a bytevector in which the words are stored in little, big or native endianness.

Function: f4l-list->bytevector list
Function: f4b-list->bytevector list
Function: f4n-list->bytevector list
Function: bytevector->f4l-list bytevector
Function: bytevector->f4b-list bytevector
Function: bytevector->f4n-list bytevector

Convert between a list of single–precision flonums and a bytevector in which the flonums are stored in little, big or native endianness.

Function: f8l-list->bytevector list
Function: f8b-list->bytevector list
Function: f8n-list->bytevector list
Function: bytevector->f8l-list bytevector
Function: bytevector->f8b-list bytevector
Function: bytevector->f8n-list bytevector

Convert between a list of double–precision flonums and a bytevector in which the flonums are stored in little, big or native endianness.

Function: c4l-list->bytevector list
Function: c4b-list->bytevector list
Function: c4n-list->bytevector list
Function: bytevector->c4l-list bytevector
Function: bytevector->c4b-list bytevector
Function: bytevector->c4n-list bytevector

Convert between a list of single–precision cflonums and a bytevector in which the cflonums are stored in little, big or native endianness, real part first.

Function: c8l-list->bytevector list
Function: c8b-list->bytevector list
Function: c8n-list->bytevector list
Function: bytevector->c8l-list bytevector
Function: bytevector->c8b-list bytevector
Function: bytevector->c8n-list bytevector

Convert between a list of double–precision cflonums and a bytevector in which the flonums are stored in little, big or native endianness, real part first.

Function: octets-encoded-bytevector? bytevector

Return #t if bytevector is a bytevector object.

Function: ascii-encoded-bytevector? bytevector

Return #t if bytevector can be interpreted as an ASCII encoded string, otherwise return #f. An octet chi is considered an ASCII code point if:

(<= #x00 chi #x7F)      ⇒ #t
Function: latin1-encoded-bytevector? bytevector

Return #t if bytevector can be interpreted as a Latin1 encoded string, otherwise return #f. iklib chars unicode latin1 for the definition of Latin-1 encoding used by Vicare.

Function: hex->bytevector bytevector
Function: bytevector->hex bytevector

Convert to and from a Scheme bytevector containing octets and a Scheme bytevector containing the ASCII hexadecimal representation of the octets.

The input hex bytevector contains the uppercase or lowercase hexadecimal representation of the octets. The output hex bytevector contains the uppercase hexadecimal representation of octets.

If an error occurs in the conversion: the return value is #f.

Function: base64->bytevector bytevector
Function: bytevector->base64 bytevector

Convert to and from a Scheme bytevector containing octets and a Scheme bytevector containing the ASCII Base64 representation of the octets.

If an error occurs in the conversion: the return value is #f.

Function: uri-encode bytevector
Function: uri-decode bytevector
Function: percent-encode bytevector
Function: percent-decode bytevector

Encode or decode a bytevector according to RFC 3986 URI percent encoding; return a bytevector. All the octets are encoded except the ones having the following ASCII representation:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789
-._~
Function: normalise-uri-encoding bytevector
Function: normalise-percent-encoding bytevector

Given a bytevector encoded according to to RFC 3986 URI percent encoding: return an encoded and normalised bytevector, octets that are encoded but should not are decoded.

Function: uri-encoded-bytevector? bv
Function: percent-encoded-bytevector? bv

Return #t if the argument is a correctly percent–encoded bytevector according to RFC 3986. This means every octet represents either one of the following characters in ASCII encoding:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789
-._~

or it is part of a percent–encoded sequence defined by the following grammar:

pct-encoded   = "%" HEXDIG HEXDIG
HEXDIG        = [0-9a-fA-F]

Next: , Previous: , Up: iklib bytevectors   [Index]