Skip to content

Commit

Permalink
Update UnicodeJsps to U13.0 and E13.1 (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
macchiati authored Jul 17, 2021
1 parent fdc77be commit 84a9500
Show file tree
Hide file tree
Showing 22 changed files with 45,118 additions and 46 deletions.
2 changes: 1 addition & 1 deletion UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeJsp.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public static String getIdentifier(String script) {

static final String VERSIONS = "Version 3.9; "
+ "ICU version: " + VersionInfo.ICU_VERSION.getVersionString(2, 2) + "; "
+ "Unicode version: " + UCharacter.getUnicodeVersion().getVersionString(2, 2) + "; "
+ "Unicode/Emoji version: " + UCharacter.getUnicodeVersion().getVersionString(2, 2) + "; "
+ (CachedProps.IS_BETA ? "Unicodeβ version: " + CachedProps.CACHED_PROPS.version.getVersionString(2, 2) + "; " : "");

public static String getVersions() {
Expand Down
32 changes: 20 additions & 12 deletions UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public abstract class UnicodeProperty extends UnicodeLabel {
.add(SAMPLE_PRIVATE_USE_AREA_A)
.add(SAMPLE_PRIVATE_USE_AREA_B)
.freeze();

public static final UnicodeSet STUFF_TO_TEST_WITH_UNASSIGNED = new UnicodeSet(STUFF_TO_TEST).addAll(UNASSIGNED).freeze();

public static boolean DEBUG = false;
Expand All @@ -90,7 +90,7 @@ public abstract class UnicodeProperty extends UnicodeLabel {

/*
* Name: Unicode_1_Name Name: ISO_Comment Name: Name Name: Unicode_1_Name
*
*
*/

public static final int UNKNOWN = 0, BINARY = 2, EXTENDED_BINARY = 3,
Expand Down Expand Up @@ -269,6 +269,14 @@ public int getMaxWidth(boolean getShortest) {
return maxValueWidth;
}

public final UnicodeSet getTrueSet() {
if (!isType(BINARY)) {
throw new IllegalArgumentException("Only applicable to binary (boolean) properties, not " + getName() +
" which is of type " + getTypeName());
}
return getSet("Yes", null);
}

public final UnicodeSet getSet(String propertyValue) {
return getSet(propertyValue, null);
}
Expand Down Expand Up @@ -324,7 +332,7 @@ public UnicodeSet getSet(PatternMatcher matcher, UnicodeSet result) {
/*
* public UnicodeSet getMatchSet(UnicodeSet result) { if (result == null)
* result = new UnicodeSet(); addAll(matchIterator, result); return result; }
*
*
* public void setMatchSet(UnicodeSet set) { matchIterator = new
* UnicodeSetIterator(set); }
*/
Expand Down Expand Up @@ -453,7 +461,7 @@ protected UnicodeMap _getUnicodeMap() {
}

UnicodeSet sameValueRanges = null;

private UnicodeSet getSameValueRanges(boolean uniformUnassigned) {
if (sameValueRanges == null) {
sameValueRanges = new UnicodeSet();
Expand Down Expand Up @@ -508,7 +516,7 @@ public int compare(Object o1, Object o2) {

/**
* Utility for managing property & non-string value aliases
*
*
*/
// TODO optimize
public static boolean equalNames(String a, String b) {
Expand Down Expand Up @@ -642,7 +650,7 @@ public static String regularize(String source, boolean titlecaseStart) {
/**
* Utility function for comparing codepoint to string without generating new
* string.
*
*
* @param codepoint
* @param other
* @return true if the codepoint equals the string
Expand Down Expand Up @@ -670,7 +678,7 @@ public static final <T extends Object> boolean equals(T a, T b) {

/**
* Utility that should be on UnicodeSet
*
*
* @param source
* @param result
*/
Expand Down Expand Up @@ -1140,7 +1148,7 @@ public static abstract class BaseProperty extends UnicodeProperty {
private static final String[] YES_VALUES = {"Yes", "Y", "T", "True"};

/**
*
*
*/
private static final String[][] YES_NO_ALIASES = new String[][] {YES_VALUES, NO_VALUES};

Expand Down Expand Up @@ -1344,7 +1352,7 @@ public UnicodeMapProperty set(UnicodeMap map) {
unicodeMap = map.freeze();
return this;
}

@Override
protected UnicodeMap _getUnicodeMap() {
return unicodeMap;
Expand Down Expand Up @@ -1400,7 +1408,7 @@ public static UnicodeSet addUntested(UnicodeSet result, boolean uniformUnassigne
if (uniformUnassigned && result.contains(UnicodeProperty.SAMPLE_UNASSIGNED)) {
result.addAll(UnicodeProperty.UNASSIGNED);
}

if (result.contains(UnicodeProperty.SAMPLE_HIGH_SURROGATE)) {
result.addAll(UnicodeProperty.HIGH_SURROGATES);
}
Expand All @@ -1410,7 +1418,7 @@ public static UnicodeSet addUntested(UnicodeSet result, boolean uniformUnassigne
if (result.contains(UnicodeProperty.SAMPLE_LOW_SURROGATE)) {
result.addAll(UnicodeProperty.LOW_SURROGATES);
}

if (result.contains(UnicodeProperty.SAMPLE_PRIVATE_USE_AREA)) {
result.addAll(UnicodeProperty.PRIVATE_USE_AREA);
}
Expand Down Expand Up @@ -1458,7 +1466,7 @@ public boolean isDefault(int cp) {
return equals(cp, value);
}
String defaultValue = getValue(SAMPLE_UNASSIGNED);
return defaultValue == null ? value == null : defaultValue.equals(value);
return defaultValue == null ? value == null : defaultValue.equals(value);
}

public boolean hasUniformUnassigned() {
Expand Down
18 changes: 10 additions & 8 deletions UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,7 @@ public static void showSet(UnicodeSet inputSetRaw, CodePointShower codePointShow
out.append("</td></tr>");
}
} else if (codePointShower.abbreviate) {
if (codePointShower.doTable) {
out.append("<tr><td colSpan='4'>");
}
codePointShower.showAbbreviated(inputSetRaw, out);
if (codePointShower.doTable) {
out.append("</td></tr>");
}
} else {
LinkedHashMap<String,UnicodeSet> items = new LinkedHashMap<String, UnicodeSet>();
String specials = "Unassigned, Private use, or Surrogates";
Expand Down Expand Up @@ -392,7 +386,7 @@ public static void showSet(UnicodeSet inputSetRaw, CodePointShower codePointShow
for (String newBlock : items.keySet()) {
UnicodeSet set = items.get(newBlock);
if (codePointShower.doTable) {
out.append("<tr><td colSpan='4'>");
out.append("<tr><td colSpan='3'>");
}
out.append("<h3>" + newBlock + "</b> <div class='ri'>items: " + numberFormat.format(set.size()) + "</div></h3>\n");
if (codePointShower.doTable) {
Expand Down Expand Up @@ -627,10 +621,15 @@ List<UnicodeProperty> getProps(String input) {
private void showAbbreviated(UnicodeSet a, Appendable out) throws IOException {
UnicodeUtilities.CodePointShower codePointShower = this;

boolean haveStrings = false;
for (UnicodeSetIterator it = new UnicodeSetIterator(a); it.nextRange();) {
int s = it.codepoint;
if (s == UnicodeSetIterator.IS_STRING) {
out.append(UnicodeUtilities.showCodePoint(it.string)).append("<br>\n");
if (!haveStrings && codePointShower.doTable) {
out.append("<tr><td colSpan='3'>");
haveStrings = true;
}
out.append(UnicodeUtilities.showCodePoint(it.string)).append("\n");
} else {
int end = it.codepointEnd;
if (end == s) {
Expand All @@ -655,6 +654,9 @@ private void showAbbreviated(UnicodeSet a, Appendable out) throws IOException {
}
}
}
if (haveStrings && codePointShower.doTable) {
out.append("</td></tr>");
}
}

String getPropString(List<UnicodeProperty> props, String codePoints, boolean shortName) {
Expand Down
23 changes: 13 additions & 10 deletions UnicodeJsps/src/main/java/org/unicode/jsp/XPropertyFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static synchronized XPropertyFactory make() {
singleton = new XPropertyFactory();
return singleton;
}

public final Factory add2(UnicodeProperty sp) {
UnicodeProperty already = getProperty(sp.getName());
if (already== null) {
Expand All @@ -49,8 +49,8 @@ public final Factory add2(UnicodeProperty sp) {
return this;
}
}
{

{
ICUPropertyFactory base = ICUPropertyFactory.make();
for (String propertyAlias : (List<String>)base.getInternalAvailablePropertyAliases(new ArrayList())) {
add(base.getProperty(propertyAlias));
Expand Down Expand Up @@ -150,23 +150,26 @@ public String transform(Integer source) {
.setMain("Script_Extensions", "scx", UnicodeProperty.ENUMERATED, "1.1")
.addValueAliases(ScriptTester.getScriptSpecialsAlternates(), false)
);

CachedProps cp = CachedProps.CACHED_PROPS;
for (String prop : cp.getAvailable()) {
add2(cp.getProperty(prop));
}
UnicodeSet Basic_Emoji = cp.getProperty("Basic_Emoji").getSet("Yes");
UnicodeSet RGI_Emoji_Modifier_Sequence = cp.getProperty("RGI_Emoji_Modifier_Sequence").getSet("Yes");
UnicodeSet RGI_Emoji_Tag_Sequence = cp.getProperty("RGI_Emoji_Tag_Sequence").getSet("Yes");
UnicodeSet RGI_Emoji_Zwj_Sequence = cp.getProperty("RGI_Emoji_Zwj_Sequence").getSet("Yes");
UnicodeSet Basic_Emoji = cp.getProperty("Basic_Emoji").getSet("Yes", null); // TODO: was .getTrueSet();
UnicodeSet Emoji_Keycap_Sequence = cp.getProperty("RGI_Emoji_Keycap_Sequence").getSet("Yes", null); // TODO: was .getTrueSet();
UnicodeSet RGI_Emoji_Modifier_Sequence = cp.getProperty("RGI_Emoji_Modifier_Sequence").getSet("Yes", null); // TODO: was .getTrueSet();
UnicodeSet RGI_Emoji_Tag_Sequence = cp.getProperty("RGI_Emoji_Tag_Sequence").getSet("Yes", null); // TODO: was .getTrueSet();
UnicodeSet RGI_Emoji_Flag_Sequence = cp.getProperty("RGI_Emoji_Flag_Sequence").getSet("Yes", null); // TODO: was .getTrueSet();
UnicodeSet RGI_Emoji_Zwj_Sequence = cp.getProperty("RGI_Emoji_Zwj_Sequence").getSet("Yes", null); // TODO: was .getTrueSet();
UnicodeSet RGI_Emoji = new UnicodeSet()
.add(Basic_Emoji)
.add(Emoji_Keycap_Sequence)
.add(RGI_Emoji_Modifier_Sequence)
.add(RGI_Emoji_Flag_Sequence)
.add(RGI_Emoji_Tag_Sequence)
.add(RGI_Emoji_Zwj_Sequence)
.freeze();
add(new UnicodeSetProperty().set(RGI_Emoji).setMain("RGI_Emoji", "RGI_Emoji", UnicodeProperty.BINARY, "13.0"));

}

private void addCollationProperty() {
Expand Down Expand Up @@ -261,7 +264,7 @@ private void addBytes(StringBuilder builder, int bytes) {
builder.append(' ');
}
first = false;
builder.append(hex);
builder.append(hex);
}
}

Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 84a9500

Please sign in to comment.