ASCII Module

This module provide convenience functions for working with ASCII strings. It's one of the few public Suave Util modules. It is not recommended to use this module outside of pure machine-to-machine communication, as people speak more languages then US english, like Mandarin, Swedish or Vietnamese, which cannot be represented in ASCII.

Functions and values

Function or value Description

ASCII.bytes s

Full Usage: ASCII.bytes s

Parameters:
    s : string

Returns: byte[]

Get the ASCII-encoding of the string.

s : string
Returns: byte[]

ASCII.bytesToBuffer s buff offset

Full Usage: ASCII.bytesToBuffer s buff offset

Parameters:
    s : string
    buff : byte[]
    offset : int

Returns: int

Get the ASCII-encoding of the string and writes it to the passed `buff` at `offset`.

s : string
buff : byte[]
offset : int
Returns: int

ASCII.decodeBase64 s

Full Usage: ASCII.decodeBase64 s

Parameters:
    s : string

Returns: string

Convert the passed string `s`, assumed to be a valid Base64 encoding, to a CLR string, going through ASCII.

s : string
Returns: string

ASCII.encodeBase64 s

Full Usage: ASCII.encodeBase64 s

Parameters:
    s : string

Returns: string

Convert the passed string `s` to ASCII and then encode the buffer with base64. This function is lossy if your CLR string contains characters which cannot be represented in ASCII.

s : string
Returns: string

ASCII.toString b

Full Usage: ASCII.toString b

Parameters:
    b : byte[]

Returns: string

Convert the full buffer `b` filled with ASCII-encoded strings into a CLR string.

b : byte[]
Returns: string

ASCII.toStringAtOffset buff index count

Full Usage: ASCII.toStringAtOffset buff index count

Parameters:
    buff : byte[]
    index : int
    count : int

Returns: string

Convert the byte array to a string, by indexing into the passed buffer `b` and taking `count` bytes from it.

buff : byte[]
index : int
count : int
Returns: string

ASCII.tryDecodeBase64 s

Full Usage: ASCII.tryDecodeBase64 s

Parameters:
    s : string

Returns: string option

Try to convert the passed string `s`, which may be a valid Base64 encoding, to a CLR string, going through ASCII.

s : string
Returns: string option