Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Displaying the value of a Unicode character

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 26-02-2010
Member
 
Join Date: Dec 2009
Posts: 192
Displaying the value of a Unicode character
  

Hello,
Here is my code
Code:
String str = new String ("?") ; 
String stru = new String ( str.getBytes(), "UTF-8" );
DevoyellationArabe.getStrDevArabe(stru);


getStrDevArabe and function is as follows:
Public static String getStrDevArabe (String str){
		 if (str.charAt(0) == '?') {
				System.out.System.out.println("B is correct +++++++++++++++++++");
			} else {
				System.out.System.out.println("This is not correct -----------------------");
			}
		 System.out.print(str.charAt(0));
		 
		return null;
		
	}
I am trying to display the Unicode character , but I think there is a problem with the code, here is the code.


Last edited by Remedy : 26-02-2010 at 01:23 AM.
Reply With Quote
  #2  
Old 26-02-2010
Member
 
Join Date: Nov 2009
Posts: 333
Re: Displaying the value of a Unicode character

Hello,
The char is always a character and not the code that is displayed (Means that your console does not support this character). To display the value of its code should display it as a int :
Code:
System.out.System.out.println( (int)s.charAt(0) );
This gives you 1576 (base 10).
And for the unicode just convert in base 16, for example:
Code:
System.out.System.out.println( Integer.toHexString(s.charAt(0)) );
Display 628
Or with Java 5 and the method printf ():
Code:
System.out.printf( "% 04x", (int)s.charAt(0) );
Reply With Quote
  #3  
Old 26-02-2010
Member
 
Join Date: Nov 2008
Posts: 240
Re: Displaying the value of a Unicode character

Hey guys
Even I had a similar kind of a problem some time back. I did as you told here but does not display what I want, knowing that the value of char is a character and Arab ن , if I change character the answer is always
Code:
char c = 'ن';
System.out.println ((int) char);
System.out.println (Integer.toHexString (char));
Any help on this. Please
Reply With Quote
  #4  
Old 26-02-2010
Member
 
Join Date: Dec 2009
Posts: 192
Re: Displaying the value of a Unicode character

Hey
Here is code which I am trying to do
Code:
import java.io. *;

public class main (

public static void main (String [] args) throws UnsupportedEncodingException (

char char = '?';
System.out.println ((int) char);
System.out.println (Integer.toHexString (char));
System.out.println ("------------------------------");
ch char = '?';
System.out.println ((int) ch);
System.out.println (Integer.toHexString (ch));

}

}
Reply With Quote
  #5  
Old 26-02-2010
Member
 
Join Date: Nov 2009
Posts: 347
Re: Displaying the value of a Unicode character

Hello,
Here is some more information on this
New line is \n
Tab is \t
Backspace is \b
Carriage return is \r
Formfeed is \f
Backslash is \\
Single quotation mark is \'
Double quotation mark is \d
Octal is \d
Hexadecimal is \xd
Unicode character is \ud

Hope this will help you.
Reply With Quote
  #6  
Old 26-02-2010
Member
 
Join Date: Nov 2009
Posts: 359
Re: Displaying the value of a Unicode character

Hello,
Just have a look at the following example
Code:
public class Jst extends JPanel {
  static JFrame frm;

  public Jst() {
    Vector ls = new Vector();
    ls.add("\u00e4pple");
    ls.add("banan");
    ls.add("p\u00e4ron");
    ls.add("orange");

    // Obtain a Swedish collator
    Collator cl = Collator.getInstance(new Locale("sv", ""));
    Collections.sort(ls, cl);

    StringBuffer rs = new StringBuffer();
    for (int i = 0; i < ls.size(); i++) {
      rs.append(ls.elementAt(i));
      rs.append(" ");
    }
    add(new JLabel(rs.toString()));
  }

  public static void main(String s[]) {
    Jst pn = new Jst();
    frm = new JFrame("Jst");
    frm.getContentPane().add("Center", pn);
    frm.pack();
    frm.setVisible(true);
  }
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Displaying the value of a Unicode character"
Thread Thread Starter Forum Replies Last Post
Nokia c7 log is displaying multiple sms for a sms having character less than 160 characters K@ttY Portable Devices 2 15-01-2012 08:59 AM
MS excel is not asking for CSV and Unicode (or UTF-8) Kshama Windows Software 5 16-07-2011 07:15 PM
What is the unicode in PHP V5.3 Abigail101 Software Development 5 19-02-2010 11:50 PM
Regular expressions for unicode Solaris Software Development 4 15-12-2009 11:20 AM
Conversion from Unicode to Hindi D_chapple Software Development 4 28-11-2009 05:48 PM


All times are GMT +5.5. The time now is 07:53 PM.