Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

22
LINES

< > BotCompany Repo | #1013295 // compareIgnoreCase_jdk - uses standard JDK method

JavaX fragment (include)

static int compareIgnoreCase_jdk(S s1, S s2) {
  if (s1 == null) ret s2 == null ? 0 : -1;
  if (s2 == null) ret 1;

  int n1 = s1.length();
  int n2 = s2.length();
  int min = Math.min(n1, n2);
  for (int i = 0; i < min; i++) {
    char c1 = s1.charAt(i);
    char c2 = s2.charAt(i);
    if (c1 != c2) {
      c1 = Character.toUpperCase(c1);
      c2 = Character.toUpperCase(c2);
      if (c1 != c2) {
        c1 = Character.toLowerCase(c1);
        c2 = Character.toLowerCase(c2);
        if (c1 != c2) ret c1-c2;
      }
    }
  }
  ret n1-n2;
}

Author comment

Began life as a copy of #1013287

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1013295
Snippet name: compareIgnoreCase_jdk - uses standard JDK method
Eternal ID of this version: #1013295/1
Text MD5: da0c1dc03038c6c5c79e1f986355c880
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-31 08:10:51
Source code size: 568 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 349 / 578
Referenced in: [show references]