The Standard ML Basis Library


The Byte structure

Bytes are 8-bit integers as provided by the Word8 structure, but with additional operations over the extended ASCII characters.


Synopsis

signature BYTE
structure Byte : BYTE

Interface

val byteToChar : Word8.word -> char
val charToByte : char -> Word8.word
val bytesToString : Word8Vector.vector -> string
val stringToBytes : string -> Word8Vector.vector
val unpackStringVec : (Word8Vector.vector * int * int option) -> string
val unpackString : (Word8Array.array * int * int option) -> string
val packString : (Word8Array.array * int * substring) -> unit

Description

byteToChar i
returns the character whose code is i.

charToByte c
returns an 8-bit word holding the code for the character c.

bytesToString v
stringToBytes s
convert between a vector of character codes and the corresponding string.
Implementation note:

In some implementations, these may be constant-time operations.



unpackStringVec (vec, i, opt)
when opt is NONE, unpackStringVec returns the string consisting of characters whose codes are held in vec[i..(length vec)-1]. Raises Subscript if i < 0 or i > length vec. When opt is SOME n, unpackStringVec returns the string consisting of characters whose codes are held in vec[i..i+n-1]. Raises Subscript if i < 0 or n < 0 or i+n > length v! ec.

unpackString (arr, i, opt)
Identical to unpackStringVec, but where arr is a Word8Array.array.

packString (s, arr, i)
puts the substring s into the array arr at offset i. Raises Subscript if i < 0 or (size s) + i > length arr.


See Also

WORD, Word8, Word8Vector, Word8Array, Char, String, Substring

[ INDEX | TOP | Parent | Root ]

Last Modified August 9, 1996
Copyright © 1996 AT&T