| Reply | « Previous Thread | Next Thread » |
|
hi every body,
i have a midlet that retreives data from sql database and display them. every thing is ok and with the numbers and with english strings but the problem is that arabic is displayed like that ???? i am sorry if this looks trivial ,i know that i need encoding or some thing to display arabic but i have no idea about encoding i am using : midp 2.0 sql 2000 nokia phone N73 for testing i am sure that my mobile supports arabic this is the code that i use to get data from the database:: <code> DataInputStream is =(DataInputStream)c.openDataInputStream(); int ch; sb = new StringBuffer(); while ((ch = is.read()) != -1) { sb.append((char)ch); } queryResult=sb.toString(); </code> queryResult looks like this "string,string,string,...." and i use subString method to separate the strings and display them any hints are appreciated raghda |
|
Does your phone firmware support arabic fonts? If not, you cannot display arabic characters in your MIDlet as there is not system support for it (and you cannot add such language pack on the phone afterwards)
Hartti |
|
Just to add what Hartti suggested, here are some previous similar discussions that would be of some interest to you.
http://discussion.forum.nokia.com/fo...ghlight=arabic http://discussion.forum.nokia.com/fo...ighlight=UTF-8 Are you using "UTF-8" charectors for encoding Arabic charectors? Regards Gopal __________________ MobiQuil.com An initiative by Developers for Developers. http://www.mobiquil.com - Alpha - Launched. |
|
hi balagopalks,
i really appreciate your reply i saw the discussions you sent me and i tried to change the encoding in eclipse t UTF-8 and i wrote String s="كتاب"; in my code and i was able to display arabic in my midlet with no more work. i understood from the discussions that its not that easy to display arabic when dealing with files or databases and this is actually my case, i am getting data from sql database and i want to display them . if you have any idea how to do that plz have a look at my code i sent at the beginnig of our discussion Thanks raghda |
|
hi every body ,
my problem has not been solved yet. please if any body can help plz do as soon as possible thanks raghda |
|
It is not much more difficult, however, you have to take care a bit more and answer these two questions:
– Is Java aware of the encoding of the input source? – No? Which encoding is used by the input source? Supply that to Java.Read of InputStream returns an byte in the range of 0x00-0xFF and not a char which is in the range of 0x0000-0xFFFF. See the Javadoc description of these classes. Again, I recommend to find a tutorial about Byte, Character and String classes. A correct way in this case would be to wrap your InputStream into an InputStreamReader object and supply the encoding of the data stream in the constructor. Then a char is returned which can be typecasted as you do. Code:
InputStream stream = c.openDataInputStream(); Reader is = new InputStreamReader(stream, encoding); However, why do you deal with a DataInputStream? DataInputStream could mean Java knowns the encoding already (see the two questions above) and all you have to do is decode the input stream as it was encoded (readChar or readUTF for example). This depends on your database code, which I do not know. You you use DataOutput there, you can even use writeUTF several times and then readUTF. This would avoid a costly splitting of the complete string.
Last edited by traud : 2007-08-07 at 14:36.
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|