public static String binaryUrlencode(byte[] bytes) {
return binaryUrlencode(bytes, 0, bytes.length);
}
public static String binaryUrlencode(byte[] bytes, int ofs, int len) {
StringBuilder stringBuilder = new StringBuilder(len*3);
for (int i = 0; i < len; i++) {
stringBuilder.append("%");
String s = "0" + Integer.toHexString(bytes[ofs+i]);
stringBuilder.append(s.substring(s.length()-2, s.length()));
}
return stringBuilder.toString().toUpperCase();
}
Began life as a copy of #2000460
Snippet is not live.
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #2000554 |
| Snippet name: | binaryUrlencode |
| Eternal ID of this version: | #2000554/1 |
| Text MD5: | 726af14b1b5cce5604b8c21dfc827b0c |
| Author: | stefan |
| Category: | |
| Type: | New Tinybrain snippet |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-08-24 20:57:45 |
| Source code size: | 513 bytes / 13 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 838 / 518 |
| Referenced in: | #1002427 - Accellerating 629 (SPIKE) #1006654 - Standard functions list 2 (LIVE, continuation of #761) #3000382 - Answer for ferdie (>> t = 1, f = 0) |