Skip to content

Commit 28d889f

Browse files
authored
Invisible Characters (applied-geodesy#529)
- Remove invisible characters via `isIdentifierIgnorable(codePoint)`
1 parent df4f029 commit 28d889f

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

JAG3D/src/org/applied_geodesy/util/io/LockFileReader.java

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,30 +122,28 @@ private String removeNonBMPCharacters(final String str) {
122122
if (str == null || str.isBlank())
123123
return str;
124124

125-
final int len = str.length();
126-
if (len == 0)
127-
return str;
128-
129-
// https://stackoverflow.com/questions/6198986/how-can-i-replace-non-printable-unicode-characters-in-java
125+
final int len = str.length();
130126
StringBuilder stringBuilder = new StringBuilder(len);
131127
for (int offset = 0; offset < len;) {
132128
int codePoint = str.codePointAt(offset);
133129
offset += Character.charCount(codePoint);
134-
135-
// Replace invisible control characters and unused code points
136-
switch (Character.getType(codePoint)) {
137-
case Character.CONTROL: // \p{Cc}
138-
case Character.FORMAT: // \p{Cf}
139-
case Character.PRIVATE_USE: // \p{Co}
140-
case Character.SURROGATE: // \p{Cs}
141-
case Character.UNASSIGNED: // \p{Cn}
142-
break;
143-
default:
144-
stringBuilder.append(Character.toChars(codePoint));
145-
break;
146-
}
130+
if (!Character.isIdentifierIgnorable(codePoint))
131+
stringBuilder.append(Character.toChars(codePoint));
132+
// else {
133+
// // Replace invisible control characters and unused code points
134+
// switch (Character.getType(codePoint)) {
135+
// case Character.CONTROL: // \p{Cc} <-- enthaelt Tab
136+
// case Character.FORMAT: // \p{Cf}
137+
// case Character.PRIVATE_USE: // \p{Co}
138+
// case Character.SURROGATE: // \p{Cs}
139+
// case Character.UNASSIGNED: // \p{Cn}
140+
// break;
141+
// default:
142+
// stringBuilder.append(Character.toChars(codePoint));
143+
// break;
144+
// }
145+
// }
147146
}
148-
149147
return stringBuilder.toString();
150148
}
151149

JAG3D/src/org/applied_geodesy/version/coordtrans/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
public class Version {
2929
private final static Map<VersionType, Integer> versions = Map.of(
3030
VersionType.ADJUSTMENT_CORE, 20230726,
31-
VersionType.USER_INTERFACE, 20241009
31+
VersionType.USER_INTERFACE, 20241011
3232
);
3333

3434
private Version() {}

JAG3D/src/org/applied_geodesy/version/jag3d/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class Version {
2929
private final static Map<VersionType, Integer> versions = Map.of(
3030
VersionType.ADJUSTMENT_CORE, 20231208,
3131
VersionType.DATABASE, 20240417,
32-
VersionType.USER_INTERFACE, 20241009
32+
VersionType.USER_INTERFACE, 20241011
3333
);
3434

3535
private Version() {}

JAG3D/src/org/applied_geodesy/version/juniform/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
public class Version {
2929
private final static Map<VersionType, Integer> versions = Map.of(
3030
VersionType.ADJUSTMENT_CORE, 20231020,
31-
VersionType.USER_INTERFACE, 20241009
31+
VersionType.USER_INTERFACE, 20241011
3232
);
3333

3434
private Version() {}

0 commit comments

Comments
 (0)