Byte
structure
signature BYTE
structure Byte
:> BYTE
Bytes are 8-bit integers as provided by the Word8
structure, but serve the dual role as elements composing the extended ASCII character set. The Byte
structure provides functions for converting values between these two roles.
val byteToChar : Word8.word -> char
val charToByte : char -> Word8.word
val bytesToString : Word8Vector.vector -> string
val stringToBytes : string -> Word8Vector.vector
val unpackStringVec : Word8VectorSlice.slice -> string
val unpackString : Word8ArraySlice.slice -> string
val packString : Word8Array.array * int * substring -> unit
byteToChar i
charToByte c
val bytesToString : Word8Vector.vector -> string
val stringToBytes : string -> Word8Vector.vector
fun bytesToString bv = CharVector.tabulate( Word8Vector.length bv, fn i => byteToChar(Word8Vector.sub(bv, i))) fun stringToBytes s = Word8Vector.tabulate( String.size s, fn i => charToByte(String.sub(s, i)))
Implementation note:
For implementations where the underlying representation of the
Word8Vector.vector
andstring
types are the same, these functions should be constant-time operations.
unpackStringVec slice
val unpackString : Word8ArraySlice.slice -> string
packString (arr, i, s)
Subscript
if i < 0 or size
s + i > |arr|.
Char
,String
,Substring
,WORD
,Word8
,Word8Vector
,Word8VectorSlice
,Word8Array
,Word8ArraySlice
Generated October 02, 2003
Last Modified August 9, 1996
Comments to John Reppy.
This document may be distributed freely over the internet as long as the copyright notice and license terms below are prominently displayed within every machine-readable copy.
Copyright © 2003 AT&T and Lucent Technologies. All rights reserved.
Permission is granted for internet users to make one paper copy for their
own personal use. Further hardcopy reproduction is strictly prohibited.
Permission to distribute the HTML document electronically on any medium
other than the internet must be requested from the copyright holders by
contacting the editors.
Printed versions of the SML Basis Manual are available from Cambridge
University Press.
To order, please visit
www.cup.org (North America) or
www.cup.cam.ac.uk (outside North America). |