Results 1 to 5 of 5
  1. #1
    arvin is offline Member
    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0

    Default Class or library for alphabetic letters

    Hi Guys (and girls?)!

    I am looking for a class or library to do an easier mapping between english letters and non-english letters. It's maybe hard to understand with words (my bad english), so i can show you my method.

    The code:

    Java Code:
    public String replaceForeign() {
    		if (language.equalsIgnoreCase("tr"))
    			for (int i = 0; i < name.length(); i++)
    				switch (name.charAt(i)) {
    				case '':
    					name.setCharAt(i, 'c');
    					break;
    				case '':
    					name.setCharAt(i, 'C');
    					break;
    				case 'ğ':
    					name.setCharAt(i, 'g');
    					break;
    				case 'Ğ':
    					name.setCharAt(i, 'G');
    					break;
    So in this case i want to convert the turkish letters to latin(english) letters. The problem is, it will take too much time to do this for all languages (excluding non-latin alphabets like arabic, hindi, chinese etc.), so is there any faster way to write this code, with help of a third-party library or something?

    Thanks in advance.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,040
    Rep Power
    10

    Default Re: Class or library for alphabetic letters

    The String class has methods for automatically replacing any pattern with another substring. You could use that.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,778
    Blog Entries
    7
    Rep Power
    21

    Default Re: Class or library for alphabetic letters

    Perhaps the Normalizer class can be of help (read the API documentation for that class).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Class or library for alphabetic letters

    Found this stack overflow thread, specifically the Normalizer part.
    Essentially you use the normaliser to break down the character into its "parts" and grab the base (ascii) value.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    arvin is offline Member
    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0

    Default Re: Class or library for alphabetic letters

    Thanks appreciate your help. The normalizer class made my work a lot easier.

    Thanks guys!

Similar Threads

  1. replace non alphabetic letters
    By arvin in forum New To Java
    Replies: 2
    Last Post: 10-31-2012, 03:55 PM
  2. Convert English letters to Tamil letters
    By srinivasmallabathula in forum New To Java
    Replies: 1
    Last Post: 10-20-2012, 03:39 PM
  3. How do you install and use a class library?
    By ConMan in forum New To Java
    Replies: 4
    Last Post: 06-07-2011, 10:39 AM
  4. Catching exception from another library (class)
    By ezilka in forum New To Java
    Replies: 15
    Last Post: 05-26-2010, 07:59 AM
  5. Search string for non-alphabetic characters
    By turnergirl24 in forum New To Java
    Replies: 5
    Last Post: 10-16-2009, 03:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •