from_string


Description:

[ CCode ( cname = "g_ascii_string_to_unsigned" ) ]
[ Version ( since = "2.54" ) ]
public static bool from_string (string str, out uint64 out_num = null, uint @base = 10, uint64 min = MIN, uint64 max = MAX) throws NumberParserError

A convenience function for converting a string to an unsigned number.

This function assumes that str contains only a number of the given base that is within inclusive bounds limited by min and max. If this is true, then the converted number is stored in out_num. An empty string is not a valid input. A string with leading or trailing whitespace is also an invalid input. A string with a leading sign (`-` or `+`) is not a valid input for the unsigned parser.

base can be between 2 and 36 inclusive. Hexadecimal numbers must not be prefixed with "0x" or "0X". Such a problem does not exist for octal numbers, since they were usually prefixed with a zero which does not change the value of the parsed number.

Parsing failures result in an error with the g_number_parser_error domain. If the input is invalid, the error code will be g_number_parser_error_invalid. If the parsed number is out of bounds - g_number_parser_error_out_of_bounds.

See ascii_strtoull if you have more complex needs such as parsing a string which starts with a number, but then has other characters.

Parameters:

str

a string

out_num

a return location for a number

min

a lower bound (inclusive)

max

an upper bound (inclusive)

base

base of a parsed number

Returns:

true if str was a number, otherwise false.