|
| ||||||||||
| Tags: datatypes, integer, string, unicode character, values |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Displaying the value of a Unicode character
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;
} Last edited by Remedy : 26-02-2010 at 01:23 AM. |
|
#2
| |||
| |||
| 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) ); And for the unicode just convert in base 16, for example: Code: System.out.System.out.println( Integer.toHexString(s.charAt(0)) ); Or with Java 5 and the method printf (): Code: System.out.printf( "% 04x", (int)s.charAt(0) ); |
|
#3
| |||
| |||
| 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)); |
|
#4
| |||
| |||
| 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));
}
} |
|
#5
| |||
| |||
| 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. |
|
#6
| |||
| |||
| 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);
}
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |