Module: stdgo.strconv
Overview
Index
-
function appendFloat(_dst:Array<UInt>, _f:Float, _fmt:UInt, _prec:Int, _bitSize:Int):Array<UInt>
-
function appendInt(_dst:Array<UInt>, _i:haxe.Int64, _base:Int):Array<UInt>
-
function appendQuote(_dst:Array<UInt>, _s:String):Array<UInt>
-
function appendQuoteRune(_dst:Array<UInt>, _r:Int):Array<UInt>
-
function appendQuoteRuneToASCII(_dst:Array<UInt>, _r:Int):Array<UInt>
-
function appendQuoteRuneToGraphic(_dst:Array<UInt>, _r:Int):Array<UInt>
-
function appendQuoteToASCII(_dst:Array<UInt>, _s:String):Array<UInt>
-
function appendQuoteToGraphic(_dst:Array<UInt>, _s:String):Array<UInt>
-
function appendUint(_dst:Array<UInt>, _i:haxe.UInt64, _base:Int):Array<UInt>
-
function formatComplex(_c:stdgo.GoComplex128, _fmt:UInt, _prec:Int, _bitSize:Int):String
-
function formatFloat(_f:Float, _fmt:UInt, _prec:Int, _bitSize:Int):String
-
function parseBool(_str:String):stdgo.Tuple<Bool, stdgo.Error>
-
function parseComplex(_s:String, _bitSize:Int):stdgo.Tuple<stdgo.GoComplex128, stdgo.Error>
-
function parseFloat(_s:String, _bitSize:Int):stdgo.Tuple<Float, stdgo.Error>
-
function parseFloatPrefix(_s:String, _bitSize:Int):stdgo.Tuple3<Float, Int, stdgo.Error>
-
function parseInt(_s:String, _base:Int, _bitSize:Int):stdgo.Tuple<haxe.Int64, stdgo.Error>
-
function parseUint(_s:String, _base:Int, _bitSize:Int):stdgo.Tuple<haxe.UInt64, stdgo.Error>
-
function quotedPrefix(_s:String):stdgo.Tuple<String, stdgo.Error>
-
function unquote(_s:String):stdgo.Tuple<String, stdgo.Error>
-
function unquoteChar(_s:String, _quote:UInt):stdgo.Tuple4<Int, Bool, String, stdgo.Error>
Constants
import stdgo.strconv.Strconv
final intSize:haxe.UInt64 = stdgo._internal.strconv.Strconv_intSize.intSize
Variables
import stdgo.strconv.Strconv
var errRange:stdgo.Error
var errSyntax:stdgo.Error
Functions
import stdgo.strconv.Strconv
function baseError
function baseError(:stdgo.GoString, :stdgo.GoString, :stdgo.GoInt):stdgo.Ref<stdgo._internal.strconv.NumError>
function bitSizeError
function bitSizeError(:stdgo.GoString, :stdgo.GoString, :stdgo.GoInt):stdgo.Ref<stdgo._internal.strconv.NumError>
Classes
import stdgo.strconv.*
class Strconv
{
if d.nd == 0 {
gotoNext = 2730285
_ = gotoNext == 2730285
mant_2730223 = 0
exp_2730210 = flt.bias
gotoNext = 2731687
gotoNext = 2730478
} else {
gotoNext = 2730478
}
_ = gotoNext == 2730478
if d.dp > 310 {
gotoNext = 2730492
_ = gotoNext == 2730492
gotoNext = 2731602
gotoNext = 2730514
} else {
gotoNext = 2730514
}
_ = gotoNext == 2730514
if d.dp < -330 {
gotoNext = 2730529
_ = gotoNext == 2730529
mant_2730223 = 0
exp_2730210 = flt.bias
gotoNext = 2731687
gotoNext = 2730638
} else {
gotoNext = 2730638
}
_ = gotoNext == 2730638
exp_2730210 = 0
_ = 0
gotoNext = 2730647
_ = gotoNext == 2730647
if d.dp > 0 {
gotoNext = 2730660
_ = gotoNext == 2730660
if d.dp >= len(powtab) {
gotoNext = 2730699
_ = gotoNext == 2730699
n_2730668 = 27
gotoNext = 2730748
} else {
gotoNext = 2730720
_ = gotoNext == 2730720
n_2730668 = powtab[d.dp]
gotoNext = 2730748
}
_ = gotoNext == 2730748
d.Shift(-n_2730668)
exp_2730210 += n_2730668
gotoNext = 2730647
} else {
gotoNext = 2730775
}
_ = gotoNext == 2730775
_ = 0
gotoNext = 2730775
_ = gotoNext == 2730775
if d.dp < 0 || d.dp == 0 && d.d[0] < 53 {
gotoNext = 2730817
_ = gotoNext == 2730817
if -d.dp >= len(powtab) {
gotoNext = 2730857
_ = gotoNext == 2730857
n_2730825 = 27
gotoNext = 2730907
} else {
gotoNext = 2730878
_ = gotoNext == 2730878
n_2730825 = powtab[-d.dp]
gotoNext = 2730907
}
_ = gotoNext == 2730907
d.Shift(n_2730825)
exp_2730210 -= n_2730825
gotoNext = 2730775
} else {
gotoNext = 2730994
}
_ = gotoNext == 2730994
exp_2730210--
if exp_2730210 < flt.bias+1 {
gotoNext = 2731145
_ = gotoNext == 2731145
n_2731149 = flt.bias + 1 - exp_2730210
d.Shift(-n_2731149)
exp_2730210 += n_2731149
gotoNext = 2731203
} else {
gotoNext = 2731203
}
_ = gotoNext == 2731203
if exp_2730210-flt.bias >= 1<<flt.expbits-1 {
gotoNext = 2731239
_ = gotoNext == 2731239
gotoNext = 2731602
gotoNext = 2731295
} else {
gotoNext = 2731295
}
_ = gotoNext == 2731295
d.Shift(int(1 + flt.mantbits))
mant_2730223 = d.RoundedInteger()
if mant_2730223 == 2<<flt.mantbits {
gotoNext = 2731431
_ = gotoNext == 2731431
mant_2730223 >>= 1
exp_2730210++
if exp_2730210-flt.bias >= 1<<flt.expbits-1 {
gotoNext = 2731492
_ = gotoNext == 2731492
gotoNext = 2731602
gotoNext = 2731538
} else {
gotoNext = 2731538
}
gotoNext = 2731538
} else {
gotoNext = 2731538
}
_ = gotoNext == 2731538
if mant_2730223&(1<<flt.mantbits) == 0 {
gotoNext = 2731569
_ = gotoNext == 2731569
exp_2730210 = flt.bias
gotoNext = 2731592
} else {
gotoNext = 2731592
}
_ = gotoNext == 2731592
gotoNext = 2731687
gotoNext = 2731602
_ = gotoNext == 2731602
mant_2730223 = 0
exp_2730210 = 1<<flt.expbits - 1 + flt.bias
overflow = true
gotoNext = 2731687
_ = gotoNext == 2731687
bits_2731712 = mant_2730223 & (uint64(1)<<flt.mantbits - 1)
bits_2731712 |= uint64((exp_2730210-flt.bias)&(1<<flt.expbits-1)) << flt.mantbits
if d.neg {
gotoNext = 2731834
_ = gotoNext == 2731834
bits_2731712 |= 1 << flt.mantbits << flt.expbits
gotoNext = 2731883
} else {
gotoNext = 2731883
}
_ = gotoNext == 2731883
return bits_2731712, overflow
gotoNext = -1
}
Strconv function appendBool
function appendBool(_dst:Array<UInt>, _b:Bool):Array<UInt>
AppendBool appends "true" or "false", according to the value of b,
to dst and returns the extended buffer.
Strconv function appendFloat
function appendFloat(_dst:Array<UInt>, _f:Float, _fmt:UInt, _prec:Int, _bitSize:Int):Array<UInt>
AppendFloat appends the string form of the floating-point number f,
as generated by FormatFloat, to dst and returns the extended buffer.
Strconv function appendInt
function appendInt(_dst:Array<UInt>, _i:haxe.Int64, _base:Int):Array<UInt>
AppendInt appends the string form of the integer i,
as generated by FormatInt, to dst and returns the extended buffer.
Strconv function appendQuote
function appendQuote(_dst:Array<UInt>, _s:String):Array<UInt>
AppendQuote appends a double-quoted Go string literal representing s,
as generated by Quote, to dst and returns the extended buffer.
Strconv function appendQuoteRune
function appendQuoteRune(_dst:Array<UInt>, _r:Int):Array<UInt>
AppendQuoteRune appends a single-quoted Go character literal representing the rune,
as generated by QuoteRune, to dst and returns the extended buffer.
Strconv function appendQuoteRuneToASCII
function appendQuoteRuneToASCII(_dst:Array<UInt>, _r:Int):Array<UInt>
AppendQuoteRuneToASCII appends a single-quoted Go character literal representing the rune,
as generated by QuoteRuneToASCII, to dst and returns the extended buffer.
Strconv function appendQuoteRuneToGraphic
function appendQuoteRuneToGraphic(_dst:Array<UInt>, _r:Int):Array<UInt>
AppendQuoteRuneToGraphic appends a single-quoted Go character literal representing the rune,
as generated by QuoteRuneToGraphic, to dst and returns the extended buffer.
Strconv function appendQuoteToASCII
function appendQuoteToASCII(_dst:Array<UInt>, _s:String):Array<UInt>
AppendQuoteToASCII appends a double-quoted Go string literal representing s,
as generated by QuoteToASCII, to dst and returns the extended buffer.
Strconv function appendQuoteToGraphic
function appendQuoteToGraphic(_dst:Array<UInt>, _s:String):Array<UInt>
AppendQuoteToGraphic appends a double-quoted Go string literal representing s,
as generated by QuoteToGraphic, to dst and returns the extended buffer.
Strconv function appendUint
function appendUint(_dst:Array<UInt>, _i:haxe.UInt64, _base:Int):Array<UInt>
AppendUint appends the string form of the unsigned integer i,
as generated by FormatUint, to dst and returns the extended buffer.
Strconv function atoi
function atoi(_s:String):stdgo.Tuple<Int, stdgo.Error>
Atoi is equivalent to ParseInt(s, 10, 0), converted to type int.
Strconv function canBackquote
function canBackquote(_s:String):Bool
CanBackquote reports whether the string s can be represented
unchanged as a single-line backquoted string without control
characters other than tab.
Strconv function formatBool
function formatBool(_b:Bool):String
FormatBool returns "true" or "false" according to the value of b.
Strconv function formatComplex
function formatComplex(_c:stdgo.GoComplex128, _fmt:UInt, _prec:Int, _bitSize:Int):String
FormatComplex converts the complex number c to a string of the
form (a+bi) where a and b are the real and imaginary parts,
formatted according to the format fmt and precision prec.
The format fmt and precision prec have the same meaning as in FormatFloat. It rounds the result assuming that the original was obtained from a complex value of bitSize bits, which must be 64 for complex64 and 128 for complex128.
Strconv function formatFloat
function formatFloat(_f:Float, _fmt:UInt, _prec:Int, _bitSize:Int):String
FormatFloat 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), 'G' ('E' for large exponents, 'f' otherwise), 'x' (-0xd.ddddp±ddd, a hexadecimal fraction and binary exponent), or 'X' (-0Xd.ddddP±ddd, a hexadecimal fraction and binary exponent).
The precision prec controls the number of digits (excluding the exponent) printed by the 'e', 'E', 'f', 'g', 'G', 'x', and 'X' formats. For 'e', 'E', 'f', 'x', and 'X', 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.
Strconv function formatInt
function formatInt(_i:haxe.Int64, _base:Int):String
FormatInt 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.
Strconv function formatUint
function formatUint(_i:haxe.UInt64, _base:Int):String
FormatUint 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.
Strconv function isGraphic
function isGraphic(_r:Int):Bool
IsGraphic reports whether the rune 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.
Strconv function isPrint
function isPrint(_r:Int):Bool
IsPrint reports whether the rune is defined as printable by Go, with
the same definition as unicode.IsPrint: letters, numbers, punctuation,
symbols and ASCII space.
Strconv function itoa
function itoa(_i:Int):String
Itoa is equivalent to FormatInt(int64(i), 10).
Strconv function mulByLog10Log2
function mulByLog10Log2(_x:Int):Int
Strconv function mulByLog2Log10
function mulByLog2Log10(_x:Int):Int
Strconv function newDecimal
function newDecimal(_i:haxe.UInt64):stdgo.strconv.T_decimal
Strconv function parseBool
function parseBool(_str:String):stdgo.Tuple<Bool, stdgo.Error>
ParseBool 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.
Strconv function parseComplex
function parseComplex(_s:String, _bitSize:Int):stdgo.Tuple<stdgo.GoComplex128, stdgo.Error>
ParseComplex converts the string s to a complex number
with the precision specified by bitSize: 64 for complex64, or 128 for complex128.
When bitSize=64, the result still has type complex128, but it will be
convertible to complex64 without changing its value.
The number represented by s must be of the form N, Ni, or N±Ni, where N stands for a floating-point number as recognized by ParseFloat, and i is the imaginary component. If the second N is unsigned, a + sign is required between the two components as indicated by the ±. If the second N is NaN, only a + sign is accepted. The form may be parenthesized and cannot contain any spaces. The resulting complex number consists of the two components converted by ParseFloat.
The errors that ParseComplex returns have concrete type *NumError and include err.Num = s.
If s is not syntactically well-formed, ParseComplex returns err.Err = ErrSyntax.
If s is syntactically well-formed but either component is more than 1/2 ULP away from the largest floating point number of the given component's size, ParseComplex returns err.Err = ErrRange and c = ±Inf for the respective component.
Strconv function parseFloat
function parseFloat(_s:String, _bitSize:Int):stdgo.Tuple<Float, stdgo.Error>
ParseFloat converts the string s to a floating-point number
with the precision specified by bitSize: 32 for float32, or 64 for float64.
When bitSize=32, the result still has type float64, but it will be
convertible to float32 without changing its value.
ParseFloat accepts decimal and hexadecimal floating-point numbers as defined by the Go syntax for [floating-point literals]. If s is well-formed and near a valid floating-point number, ParseFloat returns the nearest floating-point number rounded using IEEE754 unbiased rounding. (Parsing a hexadecimal floating-point value only rounds when there are more bits in the hexadecimal representation than will fit in the mantissa.)
The errors that ParseFloat returns have concrete type *NumError and include err.Num = s.
If s is not syntactically well-formed, ParseFloat returns err.Err = ErrSyntax.
If s is syntactically well-formed but is more than 1/2 ULP away from the largest floating point number of the given size, ParseFloat returns f = ±Inf, err.Err = ErrRange.
ParseFloat recognizes the string "NaN", and the (possibly signed) strings "Inf" and "Infinity" as their respective special floating point values. It ignores case when matching.
[floating-point literals]: https://go.dev/ref/spec#Floating-point_literals
Strconv function parseFloatPrefix
function parseFloatPrefix(_s:String, _bitSize:Int):stdgo.Tuple3<Float, Int, stdgo.Error>
Strconv function parseInt
function parseInt(_s:String, _base:Int, _bitSize:Int):stdgo.Tuple<haxe.Int64, stdgo.Error>
ParseInt interprets a string s in the given base (0, 2 to 36) and
bit size (0 to 64) and returns the corresponding value i.
The string may begin with a leading sign: "+" or "-".
If the base argument is 0, the true base is implied by the string's prefix following the sign (if present): 2 for "0b", 8 for "0" or "0o", 16 for "0x", and 10 otherwise. Also, for argument base 0 only, underscore characters are permitted as defined by the Go syntax for [integer literals].
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. If bitSize is below 0 or above 64, an error is returned.
The errors that ParseInt returns have concrete type *NumError and include err.Num = s. If s is empty or contains invalid digits, err.Err = ErrSyntax and the returned value is 0; if the value corresponding to s cannot be represented by a signed integer of the given size, err.Err = ErrRange and the returned value is the maximum magnitude integer of the appropriate bitSize and sign.
[integer literals]: https://go.dev/ref/spec#Integer_literals
Strconv function parseUint
function parseUint(_s:String, _base:Int, _bitSize:Int):stdgo.Tuple<haxe.UInt64, stdgo.Error>
ParseUint is like ParseInt but for unsigned numbers.
A sign prefix is not permitted.
Strconv function quote
function quote(_s:String):String
Quote returns a double-quoted Go string literal representing s. The
returned string uses Go escape sequences (\t, \n, \xFF, \u0100) for
control characters and non-printable characters as defined by
IsPrint.
Strconv function quoteRune
function quoteRune(_r:Int):String
QuoteRune returns a single-quoted Go character literal representing the
rune. The returned string uses Go escape sequences (\t, \n, \xFF, \u0100)
for control characters and non-printable characters as defined by IsPrint.
If r is not a valid Unicode code point, it is interpreted as the Unicode
replacement character U+FFFD.
Strconv function quoteRuneToASCII
function quoteRuneToASCII(_r:Int):String
QuoteRuneToASCII returns a single-quoted Go character literal representing
the rune. The returned string uses Go escape sequences (\t, \n, \xFF,
\u0100) for non-ASCII characters and non-printable characters as defined
by IsPrint.
If r is not a valid Unicode code point, it is interpreted as the Unicode
replacement character U+FFFD.
Strconv function quoteRuneToGraphic
function quoteRuneToGraphic(_r:Int):String
QuoteRuneToGraphic returns a single-quoted Go character literal representing
the rune. If the rune is not a Unicode graphic character,
as defined by IsGraphic, the returned string will use a Go escape sequence
(\t, \n, \xFF, \u0100).
If r is not a valid Unicode code point, it is interpreted as the Unicode
replacement character U+FFFD.
Strconv function quoteToASCII
function quoteToASCII(_s:String):String
QuoteToASCII returns a double-quoted Go string literal representing s.
The returned string uses Go escape sequences (\t, \n, \xFF, \u0100) for
non-ASCII characters and non-printable characters as defined by IsPrint.
Strconv function quoteToGraphic
function quoteToGraphic(_s:String):String
QuoteToGraphic returns a double-quoted Go string literal representing s.
The returned string leaves Unicode graphic characters, as defined by
IsGraphic, unchanged and uses Go escape sequences (\t, \n, \xFF, \u0100)
for non-graphic characters.
Strconv function quotedPrefix
function quotedPrefix(_s:String):stdgo.Tuple<String, stdgo.Error>
QuotedPrefix returns the quoted string (as understood by Unquote) at the prefix of s.
If s does not start with a valid quoted string, QuotedPrefix returns an error.
Strconv function setOptimize
function setOptimize(_b:Bool):Bool
Strconv function unquote
function unquote(_s:String):stdgo.Tuple<String, stdgo.Error>
Unquote interprets s as a single-quoted, double-quoted,
or backquoted Go 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.)
Strconv function unquoteChar
function unquoteChar(_s:String, _quote:UInt):stdgo.Tuple4<Int, Bool, String, stdgo.Error>
UnquoteChar decodes the first character or byte in the escaped string
or character literal represented by the string s.
It returns four values:
- value, the decoded Unicode code point or byte value;
- multibyte, a boolean indicating whether the decoded character requires a multibyte UTF-8 representation;
- tail, the remainder of the string after the character; and
- an error that will be nil if the character is syntactically valid.
The second argument, quote, specifies the type of literal being parsed
and therefore which escaped quote character is permitted.
If set to a single quote, it permits the sequence \' and disallows unescaped '.
If set to a double quote, it permits \" and disallows unescaped ".
If set to zero, it does not permit either escape and allows both quote characters to appear unescaped.