MCPcopy Index your code
hub / github.com/ccxt/ccxt / encodeURIComponent

Method encodeURIComponent

java/lib/src/main/java/io/github/ccxt/base/Encode.java:389–413  ·  view source on GitHub ↗
(Object str2)

Source from the content-addressed store, hash-verified

387// }
388
389 public static String encodeURIComponent(Object str2) {
390 String str = (String) str2;
391 // Match JS encodeURIComponent: unreserved set is A-Z a-z 0-9 - _ . ~ ! * ' ( )
392 // Brackets `[` `]` ARE encoded. (The previous version included them in
393 // the unreserved set to mimic C# HttpUtility output, but TS sources
394 // call encodeURIComponent expecting JS semantics — e.g. aster.cancelOrders
395 // produces `orderIdList=%5B...%5D`.)
396 String unreserved = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~!*'()";
397
398 StringBuilder result = new StringBuilder(str.length() * 3);
399
400 byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
401 for (byte b : bytes) {
402 int c = b & 0xFF;
403 char ch = (char) c;
404
405 if (unreserved.indexOf(ch) != -1) {
406 result.append(ch);
407 } else {
408 result.append('%');
409 result.append(String.format("%02X", c));
410 }
411 }
412 return result.toString();
413 }
414
415 private static String urlEncode(String s) {
416 try {

Callers 4

encodeURIComponentMethod · 0.95
encodeValuesWithJsonMethod · 0.45
signMethod · 0.45
signMethod · 0.45

Calls 4

lengthMethod · 0.45
appendMethod · 0.45
formatMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected