MCPcopy Create free account
hub / github.com/grpc/grpc-java / percentDecodeAssumedUtf8

Method percentDecodeAssumedUtf8

api/src/main/java/io/grpc/Uri.java:1094–1111  ·  view source on GitHub ↗
(@Nullable String s)

Source from the content-addressed store, hash-verified

1092 }
1093
1094 @Nullable
1095 private static String percentDecodeAssumedUtf8(@Nullable String s) {
1096 if (s == null || s.indexOf('%') == -1) {
1097 return s;
1098 }
1099
1100 ByteBuffer utf8Bytes = percentDecode(s);
1101 try {
1102 return StandardCharsets.UTF_8
1103 .newDecoder()
1104 .onMalformedInput(CodingErrorAction.REPLACE)
1105 .onUnmappableCharacter(CodingErrorAction.REPLACE)
1106 .decode(utf8Bytes)
1107 .toString();
1108 } catch (CharacterCodingException e) {
1109 throw new VerifyException(e); // Should not happen in REPLACE mode.
1110 }
1111 }
1112
1113 @Nullable
1114 private static String percentEncode(String s, BitSet allowedCodePoints) {

Callers 6

getAuthorityMethod · 0.95
getUserInfoMethod · 0.95
getHostMethod · 0.95
getPathMethod · 0.95
getFragmentMethod · 0.95

Calls 3

percentDecodeMethod · 0.95
toStringMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected