Results 1 to 3 of 3
  1. #1
    NGRaju is offline Member
    Join Date
    Sep 2008
    Posts
    1
    Rep Power
    0

    Question Reading ASCII / Unicode character in Java

    I'm having a special character .
    Unicode character is 233.

    I want to read this Unicode character from a string and convert it into another unicode character.

    Please let me know the reading and writing of Unicode characters in java.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default

    ead this Unicode character from a string and convert it into another unicode character.
    Not sure what this means. Strings are sequences of unicode characters. Unicode chars range in value from 0 to \uFFFF.
    What is the conversion you talk of? Lets use a different Unicode char to talk about, say 'a'. To convert it to the next letter 'b' you can add 1 to it. 'b' = 'a' + 1

  3. #3
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
    import javax.swing.*;
    
    public class Test {
        public static void main(String[] args) {
            JTextArea textArea = new JTextArea();
            textArea.setFont(textArea.getFont().deriveFont(18f));
            char c = '';
            int codePoint = (int)c;
            String hex = Integer.toHexString(codePoint);
            textArea.append("c = " + c + "  codePoint = " + codePoint +
                            "  hex = " + hex + "\n");
            char nextChar = (char)(codePoint + 1);
            textArea.append("nextChar = " + nextChar + "\n");
            textArea.append("'a' + 1 = " + (char)('a'+1) + "\n");
            textArea.append("codePoint for nextChar = " + (int)nextChar + "\n");
            textArea.append("char for 0x00e9 = " + (char)0x00e9 + "\n");
            textArea.append("char for \\u00e9 = " + "\u00e9");
            JOptionPane.showMessageDialog(null, new JScrollPane(textArea), "", -1);
        }
    }

Similar Threads

  1. Help unicode character
    By JT4NK3D in forum New To Java
    Replies: 3
    Last Post: 11-18-2007, 08:55 AM

Posting Permissions

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