Advertisement
rerdavies

Untitled

Mar 16th, 2020
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. Copyright notice: because the default StackOverflow CC-BY-SA license for code fragments is, in practice, unusable by develoeprs, I, Robin Davies, owner of the copyright of this code, declare that code samples are also licensed under any of the following licensing terms (you choose whichever is most convenient).
  2.  
  3. Code fragments placed in the public domain, no notice required. (c) 2020 Robin Davies. All rights released into the public domain.
  4.  
  5. Apache License 2.0. (just toss my copyright line in with all the rest of the copyright notices): Trivial code fragments (c) 2020 Robin Davies.
  6.  
  7. MIT License. (c) 2020 Robin Davies.
  8.  
  9. BSD License (any variant, including zero-clause) (c) 2020 Robin Davies. (no notice required)
  10.  
  11. Copyright (c) 2020 Robin Davies. Permission granted to use code fragments without restriction or requirement to post notices.
  12.  
  13. My personal preference (but not under any circumstance or license, a requirement) would be that you include my MIT license and notice if you link with GPL-infected code in order to not infect the fragments with GPL. My deepest sympathies.
  14.  
  15. I also place the code fragments in the public domain. But your lawyers will probably prefer the Apache 2.0 license.
  16. ---
  17.  
  18. this.collator = (RuleBasedCollator)Collator.getInstance(locale);
  19. this.collator.setStrength(Collator.PRIMARY);
  20.  
  21. ....
  22.  
  23. StringSearch search = new StringSearch(
  24. pattern,
  25. new StringCharacterIterator(targetText),
  26. collator);
  27. int index = search.first();
  28. if (index != SearchString.DONE)
  29. {
  30. // remember that the match length may NOT equal the pattern length.
  31. length = search.getMatchLength();
  32. ....
  33. }
  34.  
  35. ....
  36.  
  37. testMatch(Locale.US,"AbCde","aBcDe",true);
  38. testMatch(Locale.US,"éèê","EEE",true);
  39.  
  40. testMatch(Locale.GERMAN,"STRASSE","Straße",true);
  41. testMatch(Locale.FRENCH,"éèê","EEE",true);
  42. testMatch(Locale.FRENCH,"EEE","éèê",true);
  43. testMatch(Locale.FRENCH,"éèê","ÉÈÊ",true);
  44.  
  45. testMatch(new Locale("tr-TR"),"TITLE","tıtle",true); // Turkish dotless I/i
  46. testMatch(new Locale("tr-TR"),"TİTLE","title",true); // Turkish dotted I/i
  47. testMatch(new Locale("tr-TR"),"TITLE","title",false); // Dotless-I != dotted i.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement