Namespace: joker.strconv
v1.0Contents
Summary
Implements conversions to and from string representations of basic data types.
Index
- atoi
- can-backquote?
- format-bool
- format-double
- format-int
- graphic?
- itoa
- parse-bool
- parse-double
- parse-int
- printable?
- quote
- quote-char
- quote-char-to-ascii
- quote-char-to-graphic
- quote-to-ascii
- quote-to-graphic
- unquote
Legend
-
Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
(None.)
Variables
-
(None.)
Functions, Macros, and Special Forms
-
atoi
Function v1.0(atoi s)
Equivalent to (parse-int s 10 0).
-
can-backquote?
Function v1.0(can-backquote? s)
Reports whether the string s can be represented unchanged as a single-line backquoted string without control characters other than tab.
-
format-bool
Function v1.0(format-bool b)
Returns "true" or "false" according to the value of b.
-
format-double
Function v1.0(format-double f fmt prec bitSize)
Converts the floating-point number f to a string, according to the format fmt and precision prec. It rounds the result assuming that the original was obtained from a floating-point value of bitSize bits (32 for float32, 64 for float64).
The format fmt is one of 'b' (-ddddp±ddd, a binary exponent), 'e' (-d.dddde±dd, a decimal exponent), 'E' (-d.ddddE±dd, a decimal exponent), 'f' (-ddd.dddd, no exponent), 'g' ('e' for large exponents, 'f' otherwise), or 'G' ('E' for large exponents, 'f' otherwise).
The precision prec controls the number of digits (excluding the exponent) printed by the 'e', 'E', 'f', 'g', and 'G' formats. For 'e', 'E', and 'f' it is the number of digits after the decimal point. For 'g' and 'G' it is the maximum number of significant digits (trailing zeros are removed). The special precision -1 uses the smallest number of digits necessary such that ParseFloat will return f exactly. -
format-int
Function v1.0(format-int i base)
Returns the string representation of i in the given base, for 2 <= base <= 36. The result uses the lower-case letters 'a' to 'z' for digit values >= 10.
-
graphic?
Function v1.0(graphic? c)
Reports whether the char is defined as a Graphic by Unicode. Such characters include letters, marks, numbers, punctuation, symbols, and spaces, from categories L, M, N, P, S, and Zs.
-
itoa
Function v1.0(itoa i)
Equivalent to (format-int i 10).
-
parse-bool
Function v1.0(parse-bool s)
Returns the boolean value represented by the string. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error.
-
parse-double
Function v1.0(parse-double s)
Converts the string s to a floating-point number.
-
parse-int
Function v1.0(parse-int s base bitSize)
Interprets a string s in the given base (0, 2 to 36) and bit size (0 to 64) and returns the corresponding value i.
If base == 0, the base is implied by the string's prefix: base 16 for "0x", base 8 for "0", and base 10 otherwise. For bases 1, below 0 or above 36 an error is returned.
The bitSize argument specifies the integer type that the result must fit into. Bit sizes 0, 8, 16, 32, and 64 correspond to int, int8, int16, int32, and int64. For a bitSize below 0 or above 64 an error is returned. -
printable?
Function v1.0(printable? c)
Reports whether the char is defined as printable by Joker: letters, numbers, punctuation, symbols and ASCII space.
-
quote
Function v1.0(quote s)
Returns a double-quoted string literal representing s. The returned string uses escape sequences (\t, \n, \xFF, \u0100)
for control characters and non-printable characters as defined by printable?. -
quote-char
Function v1.0(quote-char c)
Returns a single-quoted char literal representing the character. The returned string uses escape sequences (\t, \n, \xFF, \u0100)
for control characters and non-printable characters as defined by printable?. -
quote-char-to-ascii
Function v1.0(quote-char-to-ascii c)
Returns a single-quoted char literal representing the character. The returned string uses escape sequences (\t, \n, \xFF, \u0100)
for non-ASCII characters and non-printable characters as defined by printable?. -
quote-char-to-graphic
Function v1.0(quote-char-to-graphic c)
Returns a single-quoted char literal representing the character. The returned string uses escape sequences (\t, \n, \xFF, \u0100)
for non-ASCII characters and non-printable characters as defined by graphic?. -
quote-to-ascii
Function v1.0(quote-to-ascii s)
Returns a double-quoted string literal representing s. The returned string uses escape sequences (\t, \n, \xFF, \u0100)
for non-ASCII characters and non-printable characters as defined by printable?. -
quote-to-graphic
Function v1.0(quote-to-graphic s)
Returns a double-quoted string literal representing s. The returned string uses escape sequences (\t, \n, \xFF, \u0100)
for non-ASCII characters and non-printable characters as defined by graphic?. -
unquote
Function v1.0(unquote s)
Interprets s as a single-quoted, double-quoted, or backquoted string literal, returning the string value that s quotes.
(If s is single-quoted, it would be a Go character literal; Unquote returns the corresponding one-character string.)
Types
-
(None.)