Skip to content

Commit

Permalink
Use StandardCharsets.UTF_8 constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Sep 18, 2017
1 parent 8f727d5 commit bcd0b1e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.eclipse.tm4e.core.internal.oniguruma;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

import org.jcodings.specific.UTF8Encoding;
import org.joni.Matcher;
Expand All @@ -44,12 +44,7 @@ public OnigRegExp(String source) {
lastSearchStrUniqueId = null;
lastSearchPosition = -1;
lastSearchResult = null;
byte[] pattern;
try {
pattern = source.getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
byte[] pattern = source.getBytes(StandardCharsets.UTF_8);
this.regex = new Regex(pattern, 0, pattern.length, Option.CAPTURE_GROUP, UTF8Encoding.INSTANCE, Syntax.DEFAULT,
WarnCallback.DEFAULT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.eclipse.tm4e.core.internal.oniguruma;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
* Oniguruma string.
Expand All @@ -27,15 +27,13 @@
*/
public class OnigString {

private static final String UTF_8 = "UTF-8";

private final String str;
private byte[] value;
private Object uniqueId;

public OnigString(String str) {
this.str = str;
this.value = str.getBytes(Charset.forName(UTF_8));
this.value = str.getBytes(StandardCharsets.UTF_8);
this.uniqueId = new Object();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import org.eclipse.tm4e.core.internal.parser.PList;

Expand All @@ -29,7 +30,7 @@ public JSONPListParser(boolean theme) {

public T parse(InputStream contents) throws Exception {
PList<T> pList = new PList<T>(theme);
JsonReader reader = new JsonReader(new InputStreamReader(contents, Charset.forName("UTF-8")));
JsonReader reader = new JsonReader(new InputStreamReader(contents, StandardCharsets.UTF_8));
// reader.setLenient(true);
boolean parsing = true;
while (parsing) {
Expand Down

0 comments on commit bcd0b1e

Please sign in to comment.