Merge remote-tracking branch 'origin/GP-4166_dev747368_fix_any_unicodescript_in_list' into patch

This commit is contained in:
Ryan Kurtz 2024-01-18 07:08:49 -05:00
commit 14615b508e
3 changed files with 13 additions and 4 deletions

View File

@ -29,9 +29,9 @@ public class CharacterScriptUtils {
/**
* The {@link UnicodeScript} value that represents the "ANY" choice. This is a bit of a hack
* and re-uses the INHERITED enum value for this purpose.
* and re-uses the enum value for this purpose.
*/
public static final UnicodeScript ANY_SCRIPT_ALIAS = UnicodeScript.INHERITED;
public static final UnicodeScript ANY_SCRIPT_ALIAS = UnicodeScript.UNKNOWN;
/**
* Premade examples of characters from each specified script, using info from

View File

@ -1063,7 +1063,11 @@ public class EncodedStringsDialog extends DialogComponentProvider {
private ComboBoxModel<UnicodeScript> getScriptListModel(EncodedStringsFilterStats stats) {
List<UnicodeScript> scripts = new ArrayList<>(stats.foundScriptCounts.keySet());
Collections.sort(scripts, (us1, us2) -> us1.name().compareTo(us2.name()));
Collections.sort(scripts, (us1, us2) -> {
int us1Count = stats.foundScriptCounts.get(us1);
int us2Count = stats.foundScriptCounts.get(us2);
return Integer.compare(us2Count, us1Count); // descending
});
scripts.add(0, CharacterScriptUtils.ANY_SCRIPT_ALIAS);
return new DefaultComboBoxModel<>(new Vector<>(scripts));

View File

@ -48,7 +48,12 @@ public record StringInfo(
s.codePoints().forEach(codePoint -> {
try {
UnicodeScript script = Character.UnicodeScript.of(codePoint);
scripts.add(script);
if (script == UnicodeScript.UNKNOWN) {
features.add(StringInfoFeature.CODEC_ERROR); // TODO: are we mis-using this enum to signal bad character?
}
else {
scripts.add(script);
}
if (codePoint == StringUtilities.UNICODE_REPLACEMENT) {
features.add(StringInfoFeature.CODEC_ERROR);