1 2 Previous Next 29 Replies Latest reply: May 1, 2012 2:03 PM by REDO LOG Go to original post RSS
      • 15. Re: get Encoding
        REDO LOG
        here is a test:



        public static void main(String[] args) {
                  // TODO Auto-generated method stub
                  
                  
                  char beh = '\u062F';
                  String str = new String();
                  Scanner lire = new Scanner(System.in);
                  str = lire.next();
                  char rac = str.charAt(0);
                  
                  int i = (int)beh;
                  int j = (int)rac;
                  System.out.println(beh);
                  System.out.println(i);
                  System.out.println(rac);
                  System.out.println(j);
                  


             }


        the process is:

        د
        1583
        Ø
        216

        please help i cant get it sorted

        Edited by: rachid on Apr 13, 2012 10:12 PM
        • 16. Re: get Encoding
          doremifasollatido
          rachid wrote:
          here is a test:
          ...

          the process is:

          د
          1583
          Ø
          216
          You know that 1583 decimal is the same as "062F" hexadecimal, don't you? And 216 decimal is "DB" hexadecimal, which is the correct value for that "o with stroke, Latin capital letter" that you displayed.

          Did you want to print out the hexadecimal value? There are methods in the Integer class to format int values as hexadecimal.
          • 17. Re: get Encoding
            DrClap
            And in case you didn't type the Ø character into your System.in (which you didn't say) then let me recommend you don't use your command line to test programs dealing with non-ASCII data. They have a habit of applying their own encodings and charsets which are out of your control. And if you don't have much experience with charsets, that just leads to confusion.

            I recommend using a Swing application for this sort of thing. Just make sure you're using a font which can render Arabic characters, otherwise you will see rectangles instead of characters.
            • 18. Re: get Encoding
              REDO LOG
              thank you

              but the problem is that i can't have the same value if i enter the character from the keyboard
              • 19. Re: get Encoding
                REDO LOG
                no i ddin't type type the Ø character, i typed the د

                SORRY FOR THIS i know that i disturbed all of you, but i really need to close this issue
                THANKS
                • 20. Re: get Encoding
                  DrClap
                  rachid wrote:
                  but the problem is that i can't have the same value if i enter the character from the keyboard
                  Right. That's what I said. Don't use the keyboard because that sort of thing is going to happen.
                  • 21. Re: get Encoding
                    baftos
                    Is your OS arabic?
                    • 22. Re: get Encoding
                      REDO LOG
                      No its French but i had installed the arabic language too
                      • 23. Re: get Encoding
                        REDO LOG
                        but i need to enter the character using the keyboard
                        by the way i need that in an android application
                        thank you
                        • 24. Re: get Encoding
                          baftos
                          You see, when you type in a command prompt, there are only 256 characters available. The french 256 characters code page has that slashed O exactly where the arabic 256 characters code page has your desired arabic letter. There is no way for Java to know what code page your command prompt is using, but it knows your system is French, so it assumes French. You have two options:
                          1. Do like DrClap suggests. The java GUI, as opposed to the console, supports all languages regardless of the OS. Recommended!
                          2. Use a Scanner constructor in which you specify the character set as arabic. If you are on Windows, type chcp in your console to find out what is the code page and feed this into the Scanner constructor (hardcoded or otherwise). Not recommended, unless it's a small use-once-then-throw-away program.
                          • 25. Re: get Encoding
                            baftos
                            Now I am lost with Android! Android does not even have a console! Well, I know it has one, but not for end users. Assuming you do use an Android console application, which is a a Linux console, all I said about Windows applies to that console as well, but I have no idea if you have a 'chcp' equivalent. If the final destination is Android, DrClap's suggestion makes even more sense.
                            • 26. Re: get Encoding
                              REDO LOG
                              yes i agree with you
                              here is the web version of the application:
                              http://sibawayh.emi.ac.ma/hourouf/hourouf.jsp

                              (just the first level)
                              click on English to get the English version
                              • 27. Re: get Encoding
                                baftos
                                Here is what I get in Internet Explorer:
                                type Rapport d''exception
                                message 
                                description Le serveur a rencontré une erreur interne () qui l'a empêché de satisfaire la requête.
                                exception 
                                org.apache.jasper.JasperException: java.lang.NullPointerException
                                     org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:534)
                                     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:457)
                                     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
                                     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
                                     javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
                                cause mère 
                                java.lang.NullPointerException
                                     org.apache.jsp.hourouf_jsp._jspService(hourouf_jsp.java:98)
                                     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
                                     javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
                                     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
                                     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
                                     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
                                     javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
                                note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/7.0.12.
                                Should I go there with an Android device? I don't have one right now. I am confused: Android, JSP, command line...
                                Maybe it's the language barrier. Can you step back and explain slowly what is going on? As far as I am concerned, you can do it in French.
                                • 28. Re: get Encoding
                                  796440
                                  rachid wrote:
                                  but i need to enter the character using the keyboard
                                  It's fine to enter it using the keyboard. The point is that when displaying it, you should use Swing, rather than a terminal window.
                                  • 29. Re: get Encoding
                                    REDO LOG
                                    thanks to all of the participants in this thread
                                    1 2 Previous Next