Results 1 to 18 of 18
  1. #1
    Grandon is offline Member
    Join Date
    Nov 2008
    Posts
    6
    Rep Power
    0

    Default I need help with ascii characters

    I want to display the cards symbols (diamonds, clubs, etc) for a card game I'm programming, but i don't know how to display them, can someone please give me a hand with this?
    :)

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,574
    Rep Power
    23

    Default

    Do you have images for them? How and where do you want to display them?
    What does that have to do with ascii characters?

  3. #3
    Grandon is offline Member
    Join Date
    Nov 2008
    Posts
    6
    Rep Power
    0

    Default

    I don't have any images i want to use (if it's possible) the ascii characters.
    003
    004
    005
    006
    Those are cards symbols, right?

  4. #4
    Grandon is offline Member
    Join Date
    Nov 2008
    Posts
    6
    Rep Power
    0

    Default

    oh, and I want to display them in a typical System.out window

  5. #5
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default

    I think you can just System.out.println(003);
    Maybe println("/u003"). There was a unicode example of optimization that would take a command value like //u003B and do something with it. I think there should be something similar for ASCII.

    Why not do something simple like copy the symbols from wingdings and just paste them into your code?

  6. #6
    Grandon is offline Member
    Join Date
    Nov 2008
    Posts
    6
    Rep Power
    0

    Default

    because I don't know how to do it, I'm just a novice :P

    But if you say how can i do it, I'll givie it a try.

    Thanx

  7. #7
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,574
    Rep Power
    23

    Default

    I don't know if those ascii values print as suit characters:
    System.out.println("\u0003 \u0004 \u0005"); //  
    gives me 3 squares.

  8. #8
    Grandon is offline Member
    Join Date
    Nov 2008
    Posts
    6
    Rep Power
    0

    Default Still in trouble!

    I get the same three squares, please someone help to do it in any ohter way, I really need those symbols to appear.

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,574
    Rep Power
    23

    Default

    Where do you see those symbols being printed/displayed from single Unicode characters? Do you have any web sites that show them? If so you could copy and paste them to your program

    Here's what I found. But don't know how to use them in println()
    ♥♦♣♠
    Last edited by Norm; 11-07-2008 at 12:26 AM.

  10. #10
    Grandon is offline Member
    Join Date
    Nov 2008
    Posts
    6
    Rep Power
    0

    Default RE:

    thanx, i can get them into the code but they don't appear in the window, i don't know what to do, do you know how to use them?

  11. #11
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    I don't think those symbols have ASCII values. I have few ASCII tables and anyone of them don't have those symbols.

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  13. #13
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,574
    Rep Power
    23

    Default

    I copy and pasted those 4 characters into wordpad and wrote them out as Unicode and looked at the file in a hex editor and saw the following hex values which I've coded here as Unicode:

    System.out.println("\u6526 \u6626 \u6326 \u6026"); // hearts, diamonds, club, spades

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    But you think that it will print symbols to the console in that way. I cannot do it, just get that annoying ? sign in NetBeans.

  15. #15
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,574
    Rep Power
    23

    Default

    Yup. Can't figure it out. In Wordpad, the chars are as desired. With println() then are squares or ?
    Do we need a different Font or ?

  16. #16
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Did you check those symbols on that wiki page I've post in my previous post. I tried that UNICODE on println() as well. But didn't get that symbol correctly.

  17. #17
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,574
    Rep Power
    23

    Default

    Here's some code I used to search for how to display those characters:
    Java Code:
          // Create characters and display in text area
          int firstChar = 0x2620;
          int lastChar = 0x2680;
          int nbrPerLine = 0x10;
          JTextArea textArea = new JTextArea();
          textArea.setFont(new Font("Courier New", Font.PLAIN, 20)); // This font has the chars
          textArea.append(textArea.getFont() + "\n");
    
          for(int i=firstChar; i < lastChar; i += nbrPerLine){
             StringBuffer sb = new StringBuffer(nbrPerLine);
             for(int j=0; j < nbrPerLine; j++) {
                char c = (char)(i+j);
                sb.append(c);      
             }
             // Build the display of characters one line at a time
             textArea.append(Integer.toHexString(i) + " " + sb.toString() + "\n");
          } // end for(i)
    
          JFrame f = new JFrame("Show chars");
          f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          f.getContentPane().add(new JScrollPane(textArea));
          f.pack();
          f.setVisible(true);

  18. #18
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Nice work lol. I've try the same thing, just four characters on a Label and it's working fine. But I'm failed to find a way to print them on console, I mean on println(). I guess that console does not support for UNICODE.

Similar Threads

  1. ASCII to EBCDIC conversion
    By satish kumar in forum Advanced Java
    Replies: 3
    Last Post: 06-14-2013, 01:50 PM
  2. Ascii code.........
    By Somitesh Chakraborty in forum New To Java
    Replies: 6
    Last Post: 11-04-2008, 05:32 PM
  3. Getting ASCII codes of character
    By gapper in forum New To Java
    Replies: 1
    Last Post: 02-02-2008, 09:42 AM
  4. Printing ASCII values of characters
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-21-2008, 04:36 PM

Posting Permissions

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