xdigit_value


Description:

public int xdigit_value ()

Determines the numeric value of a character as a hexadecimal digit.

Differs from xdigit_value because it takes a char, so there's no worry about sign extension if characters are signed.

Example: Convert a char-digit to hex-digit:

public static int main (string[] args) {
// Output:
// ``'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ``
// ``'A', 'B', 'C', 'D', 'E', 'F', 'a', 'b', 'c', 'd', ``
// ``'e', 'f', ``
for (int i = 0; i <= 255; i++) {
if (((char) i).xdigit_value () >= 0) {
print ("'%c', ", (char) i);
}
}
print ("\n");
return 0;
}

valac --pkg glib-2.0 char.xdigit_value.vala

Parameters:

c

an ASCII character.

Returns:

If c is a hex digit (according to isxdigit), its numeric value. Otherwise, -1.