diff --git a/UnicodeJsps/Dockerfile b/UnicodeJsps/Dockerfile index 86e90f655..fbfc7f234 100644 --- a/UnicodeJsps/Dockerfile +++ b/UnicodeJsps/Dockerfile @@ -3,7 +3,8 @@ FROM alpine as cbuild WORKDIR /build RUN apk add --update wget make gcc musl-dev ARG CPATH=https://www.unicode.org/Public/PROGRAMS/BidiReferenceC/ -ARG CVERSION=15.1.0 +# FIX_FOR_NEW_VERSION +ARG CVERSION=16.0.0 RUN wget -np -nv --reject-regex='.*\.(lib|exe)$' --cut-dirs=4 -nH -r ${CPATH}${CVERSION}/ RUN cd source && gcc -I ../include/ -static -Os -o3 -o bidiref1 bidiref1.c brutils.c brtest.c brtable.c brrule.c RUN ls -lh /build/source/bidiref1 && (/build/source/bidiref1 || true) diff --git a/UnicodeJsps/src/main/java/org/unicode/jsp/UBAVersion.java b/UnicodeJsps/src/main/java/org/unicode/jsp/UBAVersion.java index 7c351c789..2a37d83a9 100644 --- a/UnicodeJsps/src/main/java/org/unicode/jsp/UBAVersion.java +++ b/UnicodeJsps/src/main/java/org/unicode/jsp/UBAVersion.java @@ -16,7 +16,11 @@ public class UBAVersion { Age_Values.V11_0, Age_Values.V12_0, Age_Values.V13_0, - Age_Values.V14_0 + Age_Values.V14_0, + Age_Values.V15_0, + Age_Values.V15_1, + Age_Values.V16_0 + // FIX_FOR_NEW_VERSION /* Current version is always last */ ); diff --git a/UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeJsp.java b/UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeJsp.java index c57323ecf..cc1a0ccf1 100644 --- a/UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeJsp.java +++ b/UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeJsp.java @@ -13,6 +13,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -131,8 +132,15 @@ else if (choice.equals("Sentence")) public static void showProperties( int cp, String history, boolean showDevProperties, Appendable out) throws IOException { + List originalParameters = new ArrayList<>(); + if (!history.isEmpty()) { + originalParameters.add("history=" + history); + } + if (showDevProperties) { + originalParameters.add("showDevProperties=1"); + } showDevProperties = Settings.latestVersionPhase == ReleasePhase.BETA || showDevProperties; - UnicodeUtilities.showProperties(cp, history, showDevProperties, out); + UnicodeUtilities.showProperties(cp, history, showDevProperties, originalParameters, out); } static String defaultIdnaInput = @@ -201,10 +209,18 @@ public static void showSet( boolean collate, Appendable out) throws IOException { + List originalParameters = + showDevProperties ? List.of("showDevProperties=1") : List.of(); showDevProperties = Settings.latestVersionPhase == ReleasePhase.BETA || showDevProperties; CodePointShower codePointShower = new CodePointShower( - grouping, info, showDevProperties, abbreviate, ucdFormat, collate); + grouping, + info, + showDevProperties, + abbreviate, + ucdFormat, + collate, + originalParameters); UnicodeUtilities.showSetMain(a, showDevProperties, codePointShower, out); } @@ -416,8 +432,10 @@ public static String testIdnaLines(String lines, String filter) { } public static String getIdentifier(String script, boolean showDevProperties) { + List originalParameters = + showDevProperties ? List.of("showDevProperties=1") : List.of(); showDevProperties = Settings.latestVersionPhase == ReleasePhase.BETA || showDevProperties; - return UnicodeUtilities.getIdentifier(script, showDevProperties); + return UnicodeUtilities.getIdentifier(script, showDevProperties, originalParameters); } static final String VERSIONS = diff --git a/UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeUtilities.java b/UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeUtilities.java index 3e0db7834..3ba3d1706 100644 --- a/UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeUtilities.java +++ b/UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeUtilities.java @@ -40,6 +40,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; import org.unicode.cldr.tool.TablePrinter; import org.unicode.cldr.util.Predicate; import org.unicode.cldr.util.UnicodeSetPrettyPrinter; @@ -90,7 +92,7 @@ public class UnicodeUtilities { String CONTENT_RULES = "'>' > '>' ;"; - String HTML_RULES = BASE_RULES + CONTENT_RULES + "'\"' > '"' ; "; + String HTML_RULES = BASE_RULES + CONTENT_RULES + "'\"' > '"' ; '' > ''' ;"; toHTMLInput = Transliterator.createFromRules("any-xml", HTML_RULES, Transliterator.FORWARD); @@ -514,7 +516,8 @@ public static void showSet( } } - public static String getIdentifier(String script, boolean showDevProperties) { + public static String getIdentifier( + String script, boolean showDevProperties, List originalParameters) { StringBuilder result = new StringBuilder(); UnicodeProperty scriptProp = getFactory().getProperty("sc"); UnicodeSet scriptSet; @@ -560,7 +563,8 @@ public static String getIdentifier(String script, boolean showDevProperties) { showSet( allowed, showDevProperties, - new CodePointShower("", "", showDevProperties, true, false, false), + new CodePointShower( + "", "", showDevProperties, true, false, false, originalParameters), result); } @@ -580,7 +584,14 @@ public static String getIdentifier(String script, boolean showDevProperties) { showSet( items, showDevProperties, - new CodePointShower("", "", showDevProperties, true, false, false) + new CodePointShower( + "", + "", + showDevProperties, + true, + false, + false, + originalParameters) .setRestricted(true), result); } @@ -628,6 +639,7 @@ static class CodePointShower { public final boolean collate; public final List groupingProps; public final List infoProps; + public final List originalParameters; public boolean restricted; @@ -642,7 +654,8 @@ public CodePointShower( boolean showDevProperties, boolean abbreviate, boolean ucdFormat, - boolean collate) { + boolean collate, + List originalParameters) { this.groupingProps = getProps(grouping); this.infoProps = getProps(info); this.doTable = true; // !infoProps.isEmpty(); @@ -650,6 +663,7 @@ public CodePointShower( this.abbreviate = abbreviate; this.ucdFormat = ucdFormat; this.collate = collate; + this.originalParameters = originalParameters; } void showCodePoint(int codePoint, Appendable out) throws IOException { @@ -683,7 +697,8 @@ private void showString(final String string, String separator, Appendable out) + literal + "\u00A0" + "" - + UnicodeUtilities.getHex(string, separator, ucdFormat) + + UnicodeUtilities.getHex( + string, separator, ucdFormat, originalParameters) + "" + ""); } else if (ucdFormat) { - out.append(UnicodeUtilities.getHex(string, separator, ucdFormat) + " ;\t" + name); + out.append( + UnicodeUtilities.getHex(string, separator, ucdFormat, originalParameters) + + " ;\t" + + name); } else { // out.append("
\u00A0" + literal + "\u00A0
" + // UnicodeUtilities.getHex(string, separator, ucdFormat) + " \t" + name); @@ -699,7 +717,8 @@ private void showString(final String string, String separator, Appendable out) "\u00A0" + literal + "\u00A0\t" - + UnicodeUtilities.getHex(string, separator, ucdFormat) + + UnicodeUtilities.getHex( + string, separator, ucdFormat, originalParameters) + " \t" + name); if (hasJoiner) { @@ -773,7 +792,9 @@ private void showAbbreviated(UnicodeSet a, Appendable out) throws IOException { codePointShower.showCodePoint(end, out); } else { if (codePointShower.ucdFormat) { - out.append(UnicodeUtilities.getHex(s, codePointShower.ucdFormat)); + out.append( + UnicodeUtilities.getHex( + s, codePointShower.ucdFormat, originalParameters)); out.append(".."); codePointShower.showCodePoint(end, out); } else { @@ -874,25 +895,32 @@ private static String getName( return result.toString(); } - private static String getHex(int codePoint, boolean ucdFormat) { + private static String getHex( + int codePoint, boolean ucdFormat, List additionalParameters) { String hex = com.ibm.icu.impl.Utility.hex(codePoint, 4); final String string = "" - + ("") + + ("") + (ucdFormat ? "" : "U+") + hex + ""; return string; } - private static String getHex(String string, String separator, boolean ucdFormat) { + private static String getHex( + String string, String separator, boolean ucdFormat, List additionalParameters) { StringBuilder result = new StringBuilder(); int cp; for (int i = 0; i < string.length(); i += UTF16.getCharCount(cp)) { if (i != 0) { result.append(separator); } - result.append(getHex(cp = UTF16.charAt(string, i), ucdFormat)); + result.append(getHex(cp = UTF16.charAt(string, i), ucdFormat, additionalParameters)); } return result.toString(); } @@ -1377,7 +1405,12 @@ private static String getScriptCat(String versionPrefix, int cp) { } public static void showProperties( - int cp, String history, boolean showDevProperties, Appendable out) throws IOException { + int cp, + String history, + boolean showDevProperties, + List originalParameters, + Appendable out) + throws IOException { String text = UTF16.valueOf(cp); String name = getFactory().getProperty("Name").getValue(cp); @@ -1501,7 +1534,7 @@ public static void showProperties( cp, minVersion, maxVersion, - showDevProperties, + originalParameters, out); showProperties( nonUCDProperties.stream().map(UcdProperty::toString).collect(Collectors.toList()), @@ -1509,7 +1542,7 @@ public static void showProperties( cp, minVersion, maxVersion, - showDevProperties, + originalParameters, out); showProperties( ucdNonProperties.stream().map(UcdProperty::toString).collect(Collectors.toList()), @@ -1517,7 +1550,7 @@ public static void showProperties( cp, minVersion, maxVersion, - showDevProperties, + originalParameters, out); if (isUnihan) { showProperties( @@ -1526,7 +1559,7 @@ public static void showProperties( cp, minVersion, maxVersion, - showDevProperties, + originalParameters, out); } showProperties( @@ -1535,7 +1568,7 @@ public static void showProperties( cp, minVersion, maxVersion, - showDevProperties, + originalParameters, out); out.append("\n"); } @@ -1546,7 +1579,7 @@ private static void showProperties( int cp, VersionInfo minVersion, VersionInfo maxVersion, - boolean showDevProperties, + List originalParameters, Appendable out) throws IOException { out.append("" + title + "" + "\n"); @@ -1555,7 +1588,8 @@ private static void showProperties( UnicodeProperty prop = getFactory().getProperty(properties.get(i)); if (prop.getName().equals("confusable")) continue; - showPropertyValue(properties.get(i), cp, minVersion, maxVersion, out); + showPropertyValue( + properties.get(i), cp, minVersion, maxVersion, originalParameters, out); } out.append("\n"); @@ -1566,7 +1600,8 @@ private static void showProperties( UnicodeProperty prop = getFactory().getProperty(properties.get(i)); if (prop.getName().equals("confusable")) continue; - showPropertyValue(properties.get(i), cp, minVersion, maxVersion, out); + showPropertyValue( + properties.get(i), cp, minVersion, maxVersion, originalParameters, out); } out.append("\n"); out.append("\n"); @@ -1697,6 +1732,7 @@ private static void showPropertyValue( int codePoint, VersionInfo minVersion, VersionInfo maxVersion, + List originalParameters, Appendable out) throws IOException { var indexedProperty = UcdProperty.forString(propName); @@ -1714,6 +1750,8 @@ class PropertyAssignment { int span; } final boolean isMultivalued = getFactory().getProperty(propName).isMultivalued(); + final boolean isStringValued = + getFactory().getProperty(propName).isType(UnicodeProperty.STRING_MASK); List history = new ArrayList<>(); if (getFactory().getProperty(propName) instanceof IndexUnicodeProperties.IndexUnicodeProperty) { @@ -1764,13 +1802,9 @@ class PropertyAssignment { } if (history.get(0).values != null || history.size() > 1) { out.append( - "" + "" + (provisional ? "(" + propName + ")" : propName) - + ""); + + ""); for (PropertyAssignment assignment : history) { String first = assignment.first.getVersionString(2, 4) @@ -1793,7 +1827,7 @@ class PropertyAssignment { boolean isNew = assignment.first == Settings.LATEST_VERSION_INFO; String versionRange = (showVersion ? (isSingleVersion ? first : first + ".." + last) + ": " : ""); - String htmlValue = + List htmlValues = assignment.values == null ? null : assignment.values.stream() @@ -1802,39 +1836,69 @@ class PropertyAssignment { v == null ? "null" : toHTML.transliterate(v)) - .collect(Collectors.joining("|")); + .collect(Collectors.toList()); String tdClass = ""; if (assignment.values == null) { tdClass = "class='nonexistent'"; } else if (assignment.isDefault) { tdClass = "class='default'"; } + String htmlEscapedPropertyPredicate = null; + if (!isMultivalued && htmlValues != null) { + // The HTML value can contain a < even if it is not null, in the case of + // control characters. Since we do not yet support escapes in property + // predicates, just don’t give a link in that case. + if (!htmlValues.get(0).contains("<")) { + htmlEscapedPropertyPredicate = htmlValues.get(0); + } else if (assignment.values.get(0) == null) { + htmlEscapedPropertyPredicate = "@none@"; + } + } + final String href = + htmlEscapedPropertyPredicate == null + ? null + : "list-unicodeset.jsp?a=[:" + + (isCurrent ? "" : "U" + last + ":") + + propName + + "=" + + htmlEscapedPropertyPredicate + + ":]"; + final String aTag = href == null ? null : ""; + Stream displayedValues = null; + if (assignment.values != null) { + if (isStringValued && assignment.values.get(0) != null) { + displayedValues = + IntStream.range(0, assignment.values.size()) + .mapToObj( + i -> + (aTag == null ? "" : aTag) + + htmlValues.get(i) + + (aTag == null ? "" : "") + + " <" + + getHex( + assignment.values.get(i), + ", ", + false, + originalParameters) + + ">"); + } else { + displayedValues = + htmlValues.stream().map(x -> aTag == null ? x : aTag + x + ""); + } + } out.append( "" - + (assignment.values != null - ? (isMultivalued || htmlValue.contains("<") - ? "" - : ("")) + + (displayedValues != null + ? (isNew ? "" : "") + versionRange - + htmlValue - + (isMultivalued || htmlValue.contains("<") - ? "" - : "") + + (isStringValued && href != null ? "" : "") + + displayedValues.collect( + Collectors.joining("|⁠")) + + (isNew ? "" : "") : "") + ""); } diff --git a/UnicodeJsps/src/main/java/org/unicode/jsp/XPropertyFactory.java b/UnicodeJsps/src/main/java/org/unicode/jsp/XPropertyFactory.java index 1c73e10af..5d36e7df7 100644 --- a/UnicodeJsps/src/main/java/org/unicode/jsp/XPropertyFactory.java +++ b/UnicodeJsps/src/main/java/org/unicode/jsp/XPropertyFactory.java @@ -266,7 +266,7 @@ private void addExamplarProperty( add( new UnicodeProperty.UnicodeMapProperty() .set(unicodeMap) - .setMain(propertyName, propertyAbbreviation, UnicodeProperty.STRING, "1.1") + .setMain(propertyName, propertyAbbreviation, UnicodeProperty.MISC, "1.1") .addValueAliases(locales, AliasAddAction.ADD_MAIN_ALIAS) .setMultivalued(true)); } diff --git a/UnicodeJsps/src/test/java/org/unicode/jsptest/TestJsp.java b/UnicodeJsps/src/test/java/org/unicode/jsptest/TestJsp.java index b2386584a..10605ce9b 100644 --- a/UnicodeJsps/src/test/java/org/unicode/jsptest/TestJsp.java +++ b/UnicodeJsps/src/test/java/org/unicode/jsptest/TestJsp.java @@ -868,7 +868,7 @@ public void TestShowProperties() throws IOException { } public void TestIdentifiers() throws IOException { - String out = UnicodeUtilities.getIdentifier("Latin", false); + String out = UnicodeUtilities.getIdentifier("Latin", false, List.of()); assertTrue("identifier info", out.toString().contains("U+016F")); logln(out.toString()); // logln(out); diff --git a/UnicodeJsps/update-bidic-ucd.sh b/UnicodeJsps/update-bidic-ucd.sh index 8e5eb22a5..a6f0818ae 100644 --- a/UnicodeJsps/update-bidic-ucd.sh +++ b/UnicodeJsps/update-bidic-ucd.sh @@ -8,7 +8,7 @@ UCD=../unicodetools/data/ucd DEST=src/main/resources/org/unicode/jsp/bidiref1/ucd # TODO: revisit after U99.0.0 mkdir -pv ${DEST} -for dir in $(cd ${UCD} && ls -d [6789].*-Update [1-9][0-9].*-Update); do +for dir in $(cd ${UCD} && ls -d [6789].* [1-9][0-9].*); do ver=$(echo ${dir} | cut -d- -f1) for kind in UnicodeData BidiBrackets; do