Fixed code style

This commit is contained in:
Jindra Petřík
2024-08-05 11:17:25 +02:00
parent cc34fae1c5
commit 1d9329e9be
363 changed files with 8559 additions and 8277 deletions
@@ -106,9 +106,9 @@ public class Utf8Helper {
public static String stripEscapes(String string) {
return string.replaceAll("\\{invalid_utf8=[0-9]+\\}", "")
.replaceAll("\\{\\+(\\+*invalid_utf8=[0-9]+)\\}", "{$1}");
.replaceAll("\\{\\+(\\+*invalid_utf8=[0-9]+)\\}", "{$1}");
}
public static byte[] getBytes(String string) {
if (!string.contains("invalid_utf8")) {
return string.getBytes(charset);
@@ -119,7 +119,7 @@ public class Utf8Helper {
try {
Pattern invPattern = Pattern.compile("^(\\{invalid_utf8[=:]([0-9]+)\\}).*", Pattern.DOTALL);
for (int i = 0; i < string.length(); i++) {
char c = string.charAt(i);
char c = string.charAt(i);
if (c == '{') {
String subStr = string.substring(i);
if (!subStr.isEmpty() && subStr.charAt(0) == '+') {
@@ -127,7 +127,7 @@ public class Utf8Helper {
i++;
continue;
}
Matcher m = invPattern.matcher(subStr);
if (m.matches()) {
int v = Integer.parseInt(m.group(2));
@@ -136,7 +136,7 @@ public class Utf8Helper {
i--;
continue;
}
}
baos.write(("" + c).getBytes(charset));
}
@@ -150,7 +150,7 @@ public class Utf8Helper {
public static int getBytesLength(String string) {
// todo: make it faster without actually writing it to an array
return getBytes(string).length;
}
}
private static String escapeInvalidUtf8Char(int v) {
//Note: for writing the string "{invalid_utf8=xxx}" itself, you can escape it with "{+invalid_utf8=xxx}"
@@ -160,7 +160,7 @@ public class Utf8Helper {
public static String decode(byte[] data) {
return decode(data, 0, data.length);
}
public static String decode(byte[] data, int start, int length) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {