Skip to content

Commit

Permalink
[#4209] chore replace hardcoded value with std definition (#6354)
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?
Use standard definition lib value to replace the hardcoded value: UTF-8.
### Why are the changes needed?

Fix: #4209

### Does this PR introduce _any_ user-facing change?
no

### How was this patch tested?
no
  • Loading branch information
zzzk1 authored Jan 23, 2025
1 parent 8813d15 commit d99ced3
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -353,11 +352,8 @@ DER get(int... tags) {
}

String getAsString() {
try {
return new String(bb.array(), bb.arrayOffset() + bb.position(), bb.remaining(), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new IllegalCharsetNameException("UTF-8"); // won't happen.
}
return new String(
bb.array(), bb.arrayOffset() + bb.position(), bb.remaining(), StandardCharsets.UTF_8);
}

@Override
Expand Down

0 comments on commit d99ced3

Please sign in to comment.