Ignore:
Timestamp:
2018-05-26T00:47:08+02:00 (17 months ago)
Author:
Don-vip
Message:

fix #13889 - Make preset searchs ignore accents

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/AlphanumComparator.java

    r12909 r13836  
    3434import java.text.Collator;
    3535import java.util.Comparator;
    36 import java.util.Locale;
    3736
    3837/**
     
    141140            } else {
    142141                // Instantiate the collator
    143                 Collator compareOperator = Collator.getInstance(Locale.getDefault());
     142                Collator compareOperator = Collator.getInstance();
    144143                // Compare regardless of accented letters
    145144                compareOperator.setStrength(Collator.SECONDARY);
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r13716 r13836  
    3636import java.text.DateFormat;
    3737import java.text.MessageFormat;
     38import java.text.Normalizer;
    3839import java.text.ParseException;
    3940import java.util.AbstractCollection;
     
    9899    public static final String URL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=%";
    99100
     101    private static final Pattern REMOVE_DIACRITICS = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
     102
    100103    private static final char[] DEFAULT_STRIP = {'\u200B', '\uFEFF'};
    101104
     
    15591562        }
    15601563        return gvs;
     1564    }
     1565
     1566    /**
     1567     * Removes diacritics (accents) from string.
     1568     * @param str string
     1569     * @return {@code str} without any diacritic (accent)
     1570     * @since 13836 (moved from SimilarNamedWays)
     1571     */
     1572    public static String deAccent(String str) {
     1573        // https://stackoverflow.com/a/1215117/2257172
     1574        return REMOVE_DIACRITICS.matcher(Normalizer.normalize(str, Normalizer.Form.NFD)).replaceAll("");
    15611575    }
    15621576
Note: See TracChangeset for help on using the changeset viewer.