Libraryless. Click here for Pure Java version (4670L/26K).
static int[] hexToInts(S s) { if (odd(l(s))) fail("Hex string has odd length: " + quote(shorten(10, s))); int n = l(s) / 8; int[] ints = new[n]; for i to n: { int value = 0; for j to 4: { int idx = i*8+j*2; int a = parseHexChar(s.charAt(idx)); int b = parseHexChar(s.charAt(idx+1)); if (a < 0 || b < 0) fail("Bad hex byte: " + quote(substring(s, idx, idx+2)) + " at " + idx + "/" + l(s)); value |= ((a << 4) | b) << (j*8); } ints[i] = value; } ret ints; }
Began life as a copy of #1004113
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1033368 |
| Snippet name: | hexToInts |
| Eternal ID of this version: | #1033368/3 |
| Text MD5: | 93e1e0806cf4c7461581c5c13cfe145d |
| Transpilation MD5: | f3515c28b07ee2de1e047edd75b182fb |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-10-26 18:03:44 |
| Source code size: | 538 bytes / 18 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 345 / 477 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |