Results 1 to 6 of 6

Thread: String to uppercase in java

  1. #1
    Join Date
    Dec 2009
    Posts
    202

    String to uppercase in java

    Hello,
    I wanted to know if there is a function to pass the string to uppercase by removing all accents. I really do not want to create it myself. If you have some example, then it would be great. Also, if you know some information on this then please do post back.

  2. #2
    Join Date
    Nov 2009
    Posts
    518

    Re: String to uppercase in java

    Hello,
    I think you can use the replace method:
    Code:
    toString.replace("e", "e");
    toString.replace("e", "e");
    ...
    But there are probably other ways to do it.
    Hope this information will help you. If you need any more information then please feel free to post and we will try to solve your query.

  3. #3
    Join Date
    Dec 2009
    Posts
    192

    Re: String to uppercase in java

    Hello,
    Even I want to know the method which is used for the same, but I think it was not precise enough. I would also remove all Unicode characters, and other special retaining only the letters A through Z (uppercase). There are also JTextArea in the application and I must remove the line breaks, tab. I started making my way to the main characters but I Unicode blocks. Thank you for helping hands

  4. #4
    Join Date
    Nov 2009
    Posts
    446

    Re: String to uppercase in java

    Hello,
    I think you can use the regular expression for this purpose.
    Here is am example for this
    Code:
    rs = rs.replaceAll("(-|'|:|_|!|?|;|,|ยง|(|))", "");
    .....
    Hope this part of code will help you. I think you should read the documentation on java core , it can help you a lot and more precisely speaking you can read the String class. Because this is the class which provides all the functionality that you require in you program.

  5. #5
    Join Date
    Dec 2009
    Posts
    202

    Re: String to uppercase in java

    Hello,
    This is my updated code, please have a look at it.
    Code:
    Public static String toUpperCaseSansAccent(String string) {
        if (string == null)
          return null;
    
        String t = "";
        for (int i =0; I <ch.length(); I + +) {
          if (! ((ch.charAt(i) < 48 & & String.charAt(i) != 32) | | String.charAt(i) == 255 | |
                 ch.charAt(i) == 208 | | String.charAt(i) == 209 | |
                 ch.charAt(i) == 215 | | String.charAt(i) == 216 ||
                 (ch.charAt(i) < 65 & & String.charAt(i) > 57) ||
                 (ch.charAt(i) < 192 & & String.charAt(i) > 122) ||
                 (ch.charAt(i) < 65 & & String.charAt(i) > 57))) {
            t = t + ch.charAt(i);
          }
        }
        
        return t;
      }

  6. #6
    Join Date
    Nov 2009
    Posts
    343

    Re: String to uppercase in java

    Hello,
    I think even you can use the following, though I have not tried it yet, but I think this will work for you.
    Code:
    String s = "e";
    System.out.System.out.println((int) ch.charAt(0));
    You try using this in your code and see if it works, if it does not works then post back with the error which you get, because if you post errors then it is easy for us to identify the error.

Similar Threads

  1. Definition of a String in Java?
    By cloud101 in forum Software Development
    Replies: 5
    Last Post: 28-07-2014, 10:14 AM
  2. The String Class in Java
    By blueprats in forum Guides & Tutorials
    Replies: 3
    Last Post: 12-03-2010, 02:44 PM
  3. Separating a string in java
    By Aaliya Seth in forum Software Development
    Replies: 5
    Last Post: 10-02-2010, 04:27 AM
  4. Java String test
    By Aidan 12 in forum Software Development
    Replies: 3
    Last Post: 09-11-2009, 02:22 PM
  5. How to convert string into int in Java
    By Zool in forum Software Development
    Replies: 3
    Last Post: 09-11-2009, 12:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,247,945.87401 seconds with 17 queries