Here you can find the source of charArrayHexToInt(char[] str, int start, int len)
Parameter | Description |
---|---|
str | a parameter |
start | a parameter |
end | a parameter |
public static int charArrayHexToInt(char[] str, int start, int len)
//package com.java2s; public class Main { /**//from w ww . ja v a2 s. com * * @param str * @param start * @param end * @return */ public static int charArrayHexToInt(char[] str, int start, int len) { int value = 0; for (int i = start; i < start + len; i++) { value = value * 0x10; switch (str[i]) { case '0': value += 0x00; break; case '1': value += 0x01; break; case '2': value += 0x02; break; case '3': value += 0x03; break; case '4': value += 0x04; break; case '5': value += 0x05; break; case '6': value += 0x06; break; case '7': value += 0x07; break; case '8': value += 0x08; break; case '9': value += 0x09; break; case 'a': case 'A': value += 0x0a; break; case 'b': case 'B': value += 0x0b; break; case 'c': case 'C': value += 0x0c; break; case 'd': case 'D': value += 0x0d; break; case 'e': case 'E': value += 0x0e; break; case 'f': case 'F': value += 0x0f; break; default: return value; } } return value; } }