Skip to content

Instantly share code, notes, and snippets.

@vietj
Created February 4, 2019 21:23
Show Gist options
  • Select an option

  • Save vietj/8487068daddfb521c6b954a5aee84e65 to your computer and use it in GitHub Desktop.

Select an option

Save vietj/8487068daddfb521c6b954a5aee84e65 to your computer and use it in GitHub Desktop.
private static int indexOf(byte c) {
if (c == '-') {
return 26;
} else if (c >= '0' && c <= '9') {
return c;
} else if (c >= 'A' && c <= 'Z') {
return c - 'A';
} else if (c >= 'a' && c <= 'z') {
return c - 'a';
} else {
throw new IllegalArgumentException("Invalid char: " + (char) c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment