ASCII equivalent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anurag275125
    New Member
    • Aug 2009
    • 79

    ASCII equivalent

    Hi,
    Can anyone tell me how can I take a character from command line as input and find its ASCII equivalent?? Please provide coding...
  • holestary
    New Member
    • Apr 2009
    • 5

    #2
    Code:
    import java.util.*;
    public class ascii {
    
        public static void main(String args[])
        {
            Scanner input=new Scanner(System.in);
            System.out.print("enter character :");
            String k=input.next();
            int j=(int)k.charAt(0);
            System.out.println(k+"-->"+j);
        }
    }

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by holestary
      Code:
      import java.util.*;
      public class ascii {
      
          public static void main(String args[])
          {
              Scanner input=new Scanner(System.in);
              System.out.print("enter character :");
              String k=input.next();
              int j=(int)k.charAt(0);
              System.out.println(k+"-->"+j);
          }
      }
      That gives you the unicode code points for a character. Thanks for spoonfeeding.

      kind regards,

      Jos (ex-moderator)

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Here is a link to the ASCII table.

        Here is a link to the unicode table.

        Take a good look at the two tables, notice any pattern in how the two would convert to one another...descr ibe the pattern in words on paper...proceed to write a method to convert the values.


        Please take the time to research the problem before you post your question. The experts here are more than willing to help you with a specific problem but you have to do your part to learn the basics. Please take the time to read over the posting guidlines specifically the section on Before you post your question.

        Comment

        Working...