1 | public static String binaryUrlencode(byte[] bytes) { |
2 | return binaryUrlencode(bytes, 0, bytes.length); |
3 | } |
4 | |
5 | public static String binaryUrlencode(byte[] bytes, int ofs, int len) { |
6 | StringBuilder stringBuilder = new StringBuilder(len*3); |
7 | for (int i = 0; i < len; i++) { |
8 | stringBuilder.append("%"); |
9 | String s = "0" + Integer.toHexString(bytes[ofs+i]); |
10 | stringBuilder.append(s.substring(s.length()-2, s.length())); |
11 | } |
12 | return stringBuilder.toString().toUpperCase(); |
13 | } |
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: | 611 / 463 |
Referenced in: | [show references] |