Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allkeys.txt ignorables are not variable #926

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions unicodetools/src/main/java/org/unicode/text/UCA/UCA.java
Original file line number Diff line number Diff line change
Expand Up @@ -809,26 +809,21 @@ public static String toString(String sortKey, int level) {
return result.toString();
}

static final int variableBottom = UCA.getPrimary(CE_FFFE) + 1;

/*
* Produces a human-readable string for a sort key.
* removed after unicodetools svn r641
/**
* Start of variable primaries. Primary weight one higher than that for the special U+FFFE.
* https://www.unicode.org/reports/tr35/tr35-collation.html#tailored_noncharacter_weights
*/
// static public String toStringUCA(String sortKey, String original, int variableTop,
// StringBuilder extraComment)
private static final int variableBottom = UCA.getPrimary(CE_FFFE) + 1;

public static boolean isVariablePrimary(
char primary, int variableTop, boolean lastWasVariable) {
return primary == 0 ? lastWasVariable : primary <= variableTop && variableBottom <= primary;
private boolean isVariablePrimary(char primary) {
return variableBottom <= primary && primary <= ucaData.variableHigh;
}

public static String toStringUCA(CEList ceList, int variableTop, StringBuilder extraComment) {
public String toStringUCA(CEList ceList, StringBuilder extraComment) {
if (ceList == null || ceList.isEmpty()) {
return "[.0000.0000.0000]";
}
extraComment.setLength(0);
boolean lastWasVariable = false;
final StringBuffer result = new StringBuffer();

for (int i = 0; i < ceList.length(); ++i) {
Expand All @@ -837,12 +832,8 @@ public static String toStringUCA(CEList ceList, int variableTop, StringBuilder e
final char s = UCA.getSecondary(ce);
final char t = UCA.getTertiary(ce);

final boolean isVariable = isVariablePrimary(p, variableTop, lastWasVariable);

lastWasVariable = isVariable;

result.append("[")
.append(isVariable ? "*" : ".")
.append(isVariablePrimary(p) ? "*" : ".")
.append(Utility.hex(p))
.append(".")
.append(Utility.hex(s))
Expand Down Expand Up @@ -904,7 +895,7 @@ public static boolean isImplicitLeadCE(int ce) {
* from the UCA data, they are narrowed in. The first three values are used in building; the
* last two in testing.
*/
private int variableLowCE; // used for testing against
private static final int variableLowCE = makeKey(1, 0, 0); // used for testing against

private int variableHighCE; // used for testing against

Expand Down Expand Up @@ -1452,8 +1443,6 @@ private void cleanup() {
}
*/

// fixlater;
variableLowCE = makeKey(1, 0, 0);
variableHighCE =
makeKey(
ucaData.variableHigh,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static void writeAllkeys(String filename, CollatorType collatorType) throws IOEx
addString(collator, "\uFFFE", sorted);
addString(collator, "\uFFFF", sorted);

final int variableTop = CEList.getPrimary(collator.getVariableHighCE());
final StringBuilder extraComment = new StringBuilder();
for (final Entry<String, String> entry : sorted.entrySet()) {
// String key = entry.getKey();
Expand All @@ -80,7 +79,7 @@ static void writeAllkeys(String filename, CollatorType collatorType) throws IOEx
log.println(
hex
+ " ; "
+ UCA.toStringUCA(ceList, variableTop, extraComment)
+ collator.toStringUCA(ceList, extraComment)
+ " # "
+ Default.ucd().getName(value)
+ extraComment);
Expand Down
Loading