Int value of unicode character

if i do this:
char c = (char) 100023;
c should be a unicode value, but when i then do:
long l = (long)c;
i dont get 100023, i get 51447
How can i get that original number?
BTW, am i even doing any of this correct?

It should also
be able to work if it is already less than 65536....I
dont think there is such a thing but i thought i would
ask anyways.if (l < 65536) {
//it's less than 65536
} else {
//it isn't
}Now go back to the [url http://forum.java.sun.com/forum.jsp?forum=54]New to Java forum

Similar Messages

  • How to get the hex. value of unicode character

    Hi all
    I would like to get the hex. value of unicode and vice versa. I tried
    String name1 = new String(request.getParameter("textfield").getBytes("ISO8859_1"), "UTF-8");
    but it just get the unicode character, not the "hex value"
    pls help
    thx.
    Regards,
    Kin

    String str = "asdf";
    char c = str.charAt(0);
    System.out.println(Integer.toString((int)c, 16));
    Is that what you want? Or are you thinking "hex value" is something it's not, which is just a way of writing numbers in base-16.

  • Req. help on converting int value to a character(ASCII?)

    I have an array, letter[x]...where x is an int from 0 to 26. Each element is storing the freq of a particular letter in a piece of text.
    how do I convert back so that I can store the most freq letter in a string...I presume it's by using the ascii code but I don't know how.
    here's the problem code...
    if (letter[x]>currentMostCommon)
    mostCommonLetter=x; // Don't want value of x, I want ascii for letter "a" ie. x+97
    }

    Yes, it was meant to be 0-25...silly error.
    Thanks for the advice, however your suggestion gives an error:
    C:\MYDOCU~1\SUBJECTS\COMPPR~1\MYPROG~1\ASSIGN2\AnalyseText.java:61: possible loss of precision
    found : int
    required: char
                   char c= 'a' + x;
    any suggestions?
    Paul

  • Numeric value of a Character

    What is the difference between numerical value and unicode value of a character.
    Character.getNumericalValue('a'); --> returns 10
    Character.getNumericalValue('A'); --> returns 10
    System.out.println(((int)'a')); ---> outputs 97
    System.out.println(((int)'a')); ---> outputs 65
    Can any one help me understand?

    [url http://java.sun.com/j2se/1.4.1/docs/api/java/lang/Character.html#getNumericValue(char)]the api is your friend :)

  • Additional CR when printing unicode character

    Hello,
    the following code prints two lines on a printer. The second line contains an escaped unicode character. When running the example code I can't even see the unicode character on the paper; but in my original application it is visible. So this is not the problem. But always an additional carriage return is inserted after the unicode character, thus overprinting the beginning of the line with the remaining text. This did not occur in java 6 if I remember correctly. Is there any workaround for this?
    Regards
    J.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.print.*;
    import javax.swing.*;
    public class HelloWorldPrinter implements Printable, ActionListener {
        public int print(Graphics g, PageFormat pf, int page) throws
                                                            PrinterException {
            if (page > 0) return NO_SUCH_PAGE;
            Graphics2D g2d = (Graphics2D)g;
            g2d.translate(pf.getImageableX(), pf.getImageableY());
            g.drawString("Hello world!", 100, 100);
            g.drawString("Now the line with a unicode \u2259 character.", 100, 120);
            return PAGE_EXISTS;
        public void actionPerformed(ActionEvent e) {
             PrinterJob job = PrinterJob.getPrinterJob();
             job.setPrintable(this);
             boolean ok = job.printDialog();
             if (ok) {
                 try {
                      job.print();
                 } catch (PrinterException ex) {
                      System.out.println(ex);
        public static void main(String args[]) {
    //        UIManager.put("swing.boldMetal", Boolean.FALSE);
            JFrame f = new JFrame("Hello World Printer");
            f.addWindowListener(new WindowAdapter() {
               public void windowClosing(WindowEvent e) {
               System.exit(0);
            JButton printButton = new JButton("Print");
            printButton.addActionListener(new HelloWorldPrinter());
            f.add("Center", printButton);
            f.pack();
            f.setVisible(true);
    }

    Hello Sabre,
    thank you for testing. Of course it's good news that you don't see any overprinting, but unfortunately that doesn't help me on my site (Win7 64-Bit, java 1.7.0_09).
    Since I can see the character in my original application as I wrote, I made up the following test case and met a strange behaviour. I can make my desired unicode character appear without any overprinting as long as I don't use any other character in the string below 2000(16).
    Kindly run the following code. It prints a line of unicode characters starting with my desired one.
    Then change iConstant in makeTextLine() to any value below 0x2000. At my site this results in overprinting.
    Does it also happen at yours?
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.print.*;
    import javax.swing.*;
    public class UnicodeTest extends JFrame implements Printable {
      String text= "Test line with unicode \u2259 character.";
      public UnicodeTest() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(350, 200);
        text= makeTextLine();
        JLabel lb= new JLabel("<html>Printing started...<br>"+text);
        add(lb);
        setVisible(true);
        PrinterJob printerJob= PrinterJob.getPrinterJob();
        printerJob.setPrintable(this);
        try {
          printerJob.print();
        catch (PrinterException e) {
          System.out.println("PrinterException: "+e);
      public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
          public void run() {
         new UnicodeTest();
      public String makeTextLine() {
        StringBuilder sb= new StringBuilder();
        int iStartValue= 0x2259;
        int iConstant= 0x2020; // Tested with 0x100, 200, 400, 800, 1000, 2000.
        for (int i=iStartValue; i<iStartValue+30; i++) {
          sb.append((char)i);
          sb.append((char)iConstant);
        return sb.toString();
      public int print(Graphics g, PageFormat pf, int page) throws
                                                            PrinterException {
        if (page > 0) return NO_SUCH_PAGE;
        Graphics2D g2d = (Graphics2D)g;
        g2d.translate(pf.getImageableX(), pf.getImageableY());
        g2d.setFont(new Font("Dialog", Font.PLAIN, 12));
        g.drawString(text, 50, 40);
        return PAGE_EXISTS;
    }

  • Unicode character not displaying correctly

    when i am stroring Unicode Character in Oracle 8 DB .The Stored Character are not displayed correctly . Through sql client seen as '�' .Altough through JSp it displays correct value &#38598; (in japanese)
    My client wants to see through sql also same value . Pls help wat is wrong. More info :
    Oracle is set up in UTF-8 Format.
    Using code as below before inserting in DB
    String temp =product.getDescription();
    String newResult = new String(temp.getBytes("UTF-8"), "UTF-8");

    TryString newResult = new String(temp.getBytes(default),>
    "UTF-8");// "default" is a String of the name of
    default encoding on the part of client
    Sorry there was a slip. Try the following.
    String newResult = new String(temp.getBytes(default));

  • How to input unicode character set from oralce form 9i

    Hi,
    Can anyone show me how to input unicode character set from form 9i. I have designed a form and run it but when I input unicode charater in TEXT ITEM on form (FONT_NAME of this TEXT ITEM is New Roman, AriaTime l ...), but it display incorrectly nor stored it in Database.
    Thank you !

    Thank Duncan R Mills !
    My setting NLS_CHARACTER in Database as follow :
    SQL> SELECT * FROM NLS_DATABASE_PARAMETERS;
    PARAMETER VALUE
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS .,
    NLS_CHARACTERSET UTF8
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_SORT BINARY
    NLS_TIME_FORMAT HH.MI.SSXFF AM
    PARAMETER VALUE
    NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZH:TZM
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZH:TZM
    NLS_DUAL_CURRENCY $
    NLS_COMP BINARY
    NLS_NCHAR_CHARACTERSET UTF8
    NLS_RDBMS_VERSION 8.1.7.0.0
    18 rows selected.
    Even if I can'nt input unicode character on Oracle Forms, It display incorrectly though I set exactly font_name.

  • How to convwert hexadecimal value '13' to character

    In unicode program it is required to convert hexadecimal value to char. I do n't find any solution for converting hexadecimal value '13' to character.
    Please help

    You can try the following:
            CALL FUNCTION 'SCMS_BIN_TO_TEXT'
              EXPORTING
                bin_line  = '13'
              IMPORTING
                text_line = lv_char
              EXCEPTIONS
                failed    = 1
                OTHERS    = 2.
            IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.

  • Unicode character

    what is the unicode character for space? Is there one?
    if (letter == ' ') {
        //do something
    }I test here the char letter to ' ' (space) but it doesn't go into the the if even though the char letter is equal to space or ' '. So is there a unicode character like \n or some thing like that for space?
    Thank you for the help

    It's likely that the value isn't what you think. Try this statement, it'll print the decimal value of the character. For instance, a space prints x32x.
    System.out.print("x"+(short)letter+"x");

  • Unicode Character - getString - ResultSet - Java.

    Hello experts,
    I am trying to query some records, containing unicode character of fields. When i execute the query in Oracle 9i, i am able to see the unicode character in the query result.
    When sending the same sql from java, though i am getting same count of records, but the field name containing special characters, are not being visible in the rs.getString(1) method.
    Could you please help me, on getting the special character in the output.
    Your direction in this regard is highly appreciated...
    Regards,
    girig.

    Basically, i am using eclipse Ide, and seeing the
    output in the console window.Try printing the unicode hex value of the characters rather than the charcters. This way you will not be worried about whether or not the font used by the display actually has glyphs for the characters.

  • Can't read int value

    import java.io.*;
    class binary
         public static void main(String args[])
              BufferedReader br;
              int ch=0;
              br = new BufferedReader(new InputStreamReader(System.in));
              System.out.println("enter value");
              try    
                   ch = (int)br.read();
              catch(IOException e)
                   System.out.println("Exception Caught");
              System.out.println("the value entered is :" +  ch);
    }the read method used above reads an character and returns it integer value and if we want to read an integer value how to do so, i tried it in the above code but it doesn't work
    is there any specific function for reading int values or we need to use the ByteStream classes instead of the Character ones
    plz reply

    thanks it worked
    i read my number using the readLine() method as a
    String and then converted it back to an int value
    ut is there no method by which i could read values as
    int from the console n not have to do the conversion
    part.plz heply guys

  • Need help to convert this format of string in a int value?

    public static int isNumber( String number, int defaultValue ) {
              int result;
              try {
                   result = Integer.parseInt(number);
              } catch( Exception e ) {
                   result = defaultValue;
              return result;
         }Hi, I have the above method that converts a string Number into a int value. It works fine if the string is a normal number 234 (without spaces) but I have a string in the following format:
    *(space)�23,000(space).*
    That is I have a "space" then a "Pound" sign then two numbers then a comma followed by three numbers and then a space again.
    Is there any way I can convert this format into a simple int value?
    Thanks for any guidance.
    Zub

    Hi, I tried the following code but it don't seem to work
         public static int isNumberTrimSpaces( String number, int defaultValue ) {
              number.trim();
              String parsed = "";
              for (int i = 0 ; i < number.length() && number.charAt(i) != ',' ; i++)
             if (Character.isDigit(number.charAt(i))) {
             parsed += number.charAt(i);}
              int result;
              try {
                   result = Integer.parseInt(number);
              } catch( Exception e ) {
                   result = defaultValue;
              return result;
         }Any Ideas? Also will the loop get rid of the pound sign?

  • ADF Unicode character ï not displaying fine in af:outputFormatted

    Hi,
    I have a database column that stores unicode characters as : "&#239;"
    Eg : Hello&#239;
    Now &#239; represents a Unicode character.
    I am using an af:outputFormatted UI element to display this.
    The encoding for the VO which reads from the database is "UTF-8" and the PageDefinition file for the Page is also "UTF-8"
    But it is not shown as the Unicode Character but rather &#239;
    I also tried replacing it as \u00E9 and it disn;t work either too.
    Kindly help.

    <af:outputFormatted id="uni" value="#{'&#239;'}"/>
    The above code works for me so assuming your string have the proper value it should also work for you.

  • HOW can I convert int value char TO String

    I am trying to study Java by books, but sometimes it is quite difficult to find answers even to simple questions...
    I am writing a program that analyzes a Chinese text in Unicode. What I get from the text is CHAR int value (in decimals), and now I need to find them in another text file (with RegEx). But I can't find a way how to convert an INT value of a char into a String.
    Could you help me?
    Thank you in advance.

    You are confusing matters a bit. A char is a char is a char, no matter
    how you represent it. Have a look at this:char a= 'A';
    char b= 65;Both a and b have the same value. The representation of that value
    can be 'A' or 65 or even (char)('B'-1), because the decimal representation
    of 'B' is 66. Note the funny construct (char)(...). This construct casts
    the value ... back to the char type. Java performs all non-fraction
    arithmetic using four byte integers. The cast transforms it back to
    a two byte char type.
    Strings are just concatenations of zero or more chars. the charAt(i)
    method returns you the i-th char in a string. Have a look:String s= "AB";
    char a= 'A';
    char b= (char)(a+1);
    if (a == s.charAt(0)) System.out.println("yep");
    if (b == s.charAt(1)) System.out.println("yep");This piece of code prints "yep" two times. If you want to compare two
    Strings instead, you have to do this:String s= "AB";
    char a= 'A';
    char b= 'B';
    String t= ""+a+b;
    if (s.equals(t)) System.out.println("yep");Note the 'equals' method instead of the '==' operator. Also note that
    string t was constructed using those two chars. The above was a
    shorthand of something like this:StringBuffer sb= new StringBuffer("");
    sb.append(a);
    sb.append(b);
    String t= sb.toString();This is all handled by the compiler, for now, you can simply use the '+'
    operator if you want to append a char to a string. Note that it is not
    very efficient, but it'll do for now.
    Does this get your started?
    kind regards,
    Jos

  • Testing New Unicode Character (Music Symbol)

    I am trying to test the new Unicode character by using J2SE1.5.
    For example, If I wanted to test the music symbol "1D15F", how do we test that or how do we write code?
    The following is my code.
    import java.text.*;
    import java.util.*;
    import java.lang.Character.*;
    public class NewUnicodeCharacterTest {
    public static void main (String[] args) {
    String quarternote = "\u1D15F";
    System.out.println (quarternote);
    my output was
    What is wrong?

    Looking at the Java 1.5 API, I figured out that you should be able to create a string with UTF-32 code points by specifying an int[]:
    String s = new String(new int[] { 0x1D15F }, 0, 1);
    Note that System.out.println() will fail unless your console supports a codepage which contains the symbol in question. You can work around this by drawing your string onto a swing component. I tried this (using the J2SE 1.5 alpha, not beta), but I couldn't get the quarter note symbol -- maybe it's not supported in the font.

Maybe you are looking for

  • DVD drive light on Satellite M50 does not turning OFF, drive not reading CDs/DVDs

    Hello, I have a Satellite M50-mx5 with a Mat****a DVD drive. When I insert CDs or DVDs, the drive starts up, spins the CD around (the light is blinking)...but a few seconds later, the drive stops spinning, but the DVD drive light remains on. Windows

  • WHEN-TREE-NODE-EXPANDED not fire with keyboard in FORMS 10G

    I have a Hierarchical Tree. When i click in any node with mouse, works fine. When i use the key rigth and left of the keyboard, the tree expanded, but not fire the WHEN-TREE-NODE-EXPANDED. In FORMS 6i works fine.

  • Need help with method calling

    I have a problem with method calling as it does the method but doesn't send the values to the main program. The Need section in the main should take in the Max and Allocation arrays from the setMax and setAllocation but it doesn't. I figure I'm missi

  • InDesign CC sehr langsam gegenüber CS6 – was mach ich falsch?

    Hallo Adobe Community. Ich hätte da mal eine Frage bzgl. InDesign CC. InDesign CC ist gegenüber CS6 beim skalieren, verschieben, ändern der Proportionen eines Objektes dermaßen zäh das man nicht damit arbeiten kann. Ich bin maßlos enttäuscht von dem

  • Cannot use Music Store! Cannot download the problematic iTunes 7 either!

    Ok. So, now there are instructions to downgrade because of all the problems because of iTunes 7.0. BUT- we cannot use the music store! I have iTunes 6.4 I think nd it will not let me use the store to buy anything. But, I cannot get iTunes 7.0 to inst