Skip to content

Commit

Permalink
Move codepointToString to Strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mwilliamson committed Jun 10, 2024
1 parent dad0679 commit 40229a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.zwobble.mammoth.internal.util.Maps.entry;
import static org.zwobble.mammoth.internal.util.Maps.lookup;
import static org.zwobble.mammoth.internal.util.Sets.set;
import static org.zwobble.mammoth.internal.util.Strings.codepointToString;

class StatefulBodyXmlReader {
private static final Set<String> IMAGE_TYPES_SUPPORTED_BY_BROWSERS = set(
Expand Down Expand Up @@ -408,15 +409,6 @@ private ReadResult readSymbol(XmlElement element) {
);
}

public String codepointToString(int codePoint) {
if (Character.isBmpCodePoint(codePoint)) {
return String.valueOf((char) codePoint);
} else {
return String.valueOf(Character.highSurrogate(codePoint)) +
Character.lowSurrogate(codePoint);
}
}

private ReadResult readBreak(XmlElement element) {
String breakType = element.getAttributeOrNone("w:type").orElse("textWrapping");
switch (breakType) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/zwobble/mammoth/internal/util/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ public static boolean isNullOrEmpty(String value) {
public static boolean startsWithIgnoreCase(String value, String prefix) {
return value.regionMatches(true, 0, prefix, 0, prefix.length());
}

public static String codepointToString(int codePoint) {
if (Character.isBmpCodePoint(codePoint)) {
return String.valueOf((char) codePoint);
} else {
return String.valueOf(Character.highSurrogate(codePoint)) +
Character.lowSurrogate(codePoint);
}
}
}

0 comments on commit 40229a5

Please sign in to comment.