Results 1 to 9 of 9
  1. #1
    AlejandroPe's Avatar
    AlejandroPe is offline Member
    Join Date
    Mar 2009
    Posts
    37
    Rep Power
    0

    Lightbulb [SOLVED] special characters (ASCII)

    Hello everyone!
    I wonder how to write these special characters
    in my applications and applets .

    \206 \204 \224 \217 did work when I studied and worked with C++. Now I only get ? ? ? symbols when I run my Javas. :mad:

    Take a look at this code:
    Java Code:
    import java.io.*;
    import java.util.*;
    import java.applet.*;
    import java.awt.*;
    
    public class TalnamnApplet extends Applet {
    
    public static void main(String [] args){
    
    {
    Scanner scanner = new Scanner(System.in);
    System.out.println("Ange ett talnamn, fr\206n ett till nio:");
    String namn = scanner.next();
    	if (namn.equalsIgnoreCase("ett"))
    		System.out.println("Nummret r 1");
    		else if (namn.equalsIgnoreCase("tv")){
    			System.out.println("Nummret r 2");
    		}
    		else if (namn.equalsIgnoreCase("tre")){
    			System.out.println("Nummret r 3");
    		}
    		else if (namn.equalsIgnoreCase("fyra")){
    			System.out.println("Nummret r 4");
    		}
    		else if (namn.equalsIgnoreCase("fem")){
    			System.out.println("Nummret r 5");
    		}
    		else if (namn.equalsIgnoreCase("sex")){
    			System.out.println("Nummret r 6");
    		}
    		else if (namn.equalsIgnoreCase("sju")){
    			System.out.println("Nummret r 7");
    		}
    		else if (namn.equalsIgnoreCase("tta")){
    			System.out.println("Nummret r 8");
    		}
    	 	else if (namn.equalsIgnoreCase("nio")){
    			System.out.println("Nummret r 9");
    		}	 
    }
    }}

  2. #2
    Bluefox815 is offline Member
    Join Date
    Feb 2008
    Location
    Oregon, USA
    Posts
    49
    Rep Power
    0

    Default

    Try casting the ascii number to a character. You have to concatenate the character to the string to do this.

    Java Code:
    System.out.println("Ange ett talnamn, fr" + (char) 206 + "n ett till nio:");
    If that still doesn't work, you might try using 'u206' instead of '(char) 206'.

  3. #3
    AlejandroPe's Avatar
    AlejandroPe is offline Member
    Join Date
    Mar 2009
    Posts
    37
    Rep Power
    0

    Unhappy it doesn't work

    Thanks Bluefox but i still get strange symbols from the ASCII table but not the one expected, I tried several times with others symbols and did work, but not with those I want :mad: !!!

    any other solutions?:confused:

    Do I need something like a pluggin or what? :confused::mad::confused::mad:

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Perhaps you are running into a limitation of your java console, and it's time to show your output in a GUI such as a Swing app.

  5. #5
    Bluefox815 is offline Member
    Join Date
    Feb 2008
    Location
    Oregon, USA
    Posts
    49
    Rep Power
    0

    Default



    http://gallery.techarena.in/data/500...emextended.JPG

    That's a chart of extended ascii characters. You also need to know what format your number is in (decimal, hexadecimal, etc.). You might be trying to print 0x0206, instead of decimal 206 (0xCE). Just some things to think about.

  6. #6
    AlejandroPe's Avatar
    AlejandroPe is offline Member
    Join Date
    Mar 2009
    Posts
    37
    Rep Power
    0

    Default

    How can I do that? :D

    Perhaps you are running into a limitation of your java console, and it's time to show your output in a GUI such as a Swing app.

  7. #7
    Bluefox815 is offline Member
    Join Date
    Feb 2008
    Location
    Oregon, USA
    Posts
    49
    Rep Power
    0

    Default

    Instead of:

    Java Code:
    String myText = "Hello world";
    System.out.println(myText);
    Do this (you need to put the JTextArea in a JApplet/JFrame, not an Applet)

    Java Code:
    JTextArea ta = new JTextArea(5, 5);
    
    String myText = "Hello world";
    ta.setText(myText);

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    the way to learn to create Swing apps is to go through the Sun Swing tutorial. You can find it here: Lesson: Using Swing Components (The Java Tutorials > Creating a GUI with JFC/Swing)

  9. #9
    AlejandroPe's Avatar
    AlejandroPe is offline Member
    Join Date
    Mar 2009
    Posts
    37
    Rep Power
    0

    Default

    Sorry, but the solutions provided are much more advanced than my level of Java-programing. These are my very first programs.
    Thank you very much so far.

Similar Threads

  1. Replies: 1
    Last Post: 03-27-2009, 11:18 AM
  2. Searching for Microsoft special characters
    By Tim McDaniel in forum Eclipse
    Replies: 2
    Last Post: 02-24-2009, 04:11 PM
  3. special characters
    By ravian in forum New To Java
    Replies: 2
    Last Post: 11-16-2007, 02:28 PM
  4. Replies: 1
    Last Post: 08-07-2007, 06:32 AM
  5. Special characters in text fields
    By Felissa in forum Web Frameworks
    Replies: 0
    Last Post: 06-27-2007, 05:47 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
  •