In the line you need to replace all the letters "і" Ukrainian with the letters "i" English

private String ChangeI (String strChangeLine) { String strChangeResult = ""; Character charTmp; String strTmp=""; for (int iteration = 0; iteration < strChangeLine.length(); iteration++) { charTmp= strChangeLine.charAt(iteration); strTmp = charTmp.toString(); String str1 = "i"; String str2 = "І"; byte[] strCode1 = str1.getBytes(); byte[] strCode2 = str2.getBytes(); System.out.println(str1.getBytes()); System.out.println(str2.getBytes()); if (strTmp.getBytes() == strCode1) strTmp = "i" ; if (strTmp.getBytes() == strCode2) strTmp = "I" ; strChangeResult+=strTmp; } System.out.println(strChangeResult); return(strChangeResult); } 

I wrote this method here, but it does not work correctly, tell me who can distinguish between English and Cyrillic "i"

1 answer 1

  • Ukrainian "i" - \u0456
  • Latin "i" - \u0069
  • GetByte returned me for some reason [B @ 9304b1 [B @ 190d11 What are some other ways to turn a letter into a code, and vice versa? - OstapKO
  • one
    because getBytes returns an array of bytes , and unicode characters are not single-byte. Moreover, it is not clear why an array should be compared with a string. Than you are not satisfied with s.replace('\u0456', '\u0069') ? - Nofate
  • Thanks for the help, I did not consider the option with Replace, because I thought that the movement concerns only the first symbol found and not all - OstapKO
  • and where can I get the code to the big bukavm I? - OstapKO
  • Everything, I already found - the symbol table in Windows, there are all the codes - OstapKO