Skip to content

Commit

Permalink
Use standard character sets
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Mar 19, 2024
1 parent 107cb4d commit f847c86
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,7 @@ public AnnotatedLargeText<? extends FlowNode> getLogText() {
} catch (IOException e) {
ByteBuffer buf = new ByteBuffer();
PrintStream ps;
try {
ps = new PrintStream(buf, false, "UTF-8");
} catch (UnsupportedEncodingException x) {
throw new AssertionError(x);
}
ps = new PrintStream(buf, false, StandardCharsets.UTF_8);
ps.println("Failed to find log file for id="+parent.getId());
e.printStackTrace(ps);
ps.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,8 @@ public POSTHyperlinkNote(String url, int length) {
*/
private static String encodeForJavascript(String str) {
// https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
try {
String encode = URLEncoder.encode(str, StandardCharsets.UTF_8.name());
return Base64.getUrlEncoder().encodeToString(encode.getBytes(StandardCharsets.UTF_8));
} catch (UnsupportedEncodingException e) {
throw new InternalError("UTF-8 is missing but mandated by the JVM specification", e);
}
String encode = URLEncoder.encode(str, StandardCharsets.UTF_8);
return Base64.getUrlEncoder().encodeToString(encode.getBytes(StandardCharsets.UTF_8));
}

// TODO why does there need to be a descriptor at all?
Expand Down

0 comments on commit f847c86

Please sign in to comment.