| Reply | « Previous Thread | Next Thread » |
|
hey :D
trying to read a hebrew text file (that i have inside my jar) no matter what i do with the encodings (of the file itself or the way i read it) i keep getting messed up string on the emulator (and on a real phone). altho if i dont use any special encodings (Ansi) and print my text out with System.out i can see the text just fine (on the IDE's output window that is) so wondering if anyone has any idea? maybe im not using the right encodings? any help would be appriciated :D |
|
Edit the hebrew descriptions and saved in UTF-8 format. Assuming your text file contains value pairs delimited by an = sign with each value separated by a carriage return then you could use the code beneath to parse the text file. What's important is that you encode the string values to UTF-8 for them to display correctly. Depending on the phone and wether you are using standard forms or canvases you may need to reverse the string value
InputStream is = getClass().getResourceAsStream ("/hebrew.properties"); isr = new DataInputStream(is); if (isr != null) { int c, idx; int i = 0, msgid = 0; byte cb[] = new byte[1]; byte buf[] = new byte[100]; String l; while ((c = isr.read(cb, 0, 1)) != -1) { if (cb[0] == (byte)'\n' || cb[0] == '\r') { l = new String(buf, 0, i, "UTF-8"); // DO SOMETHING WITH THE STRING } else { buf[i++] = cb[0]; } } } |
|
that's just what i tried, but i got it now thanks, was encoding the string i displayed with System.out instead of the one i showed on the screen, good thinking on my part eh? :P
thanks for the help though :) |
|
I tried the method discussed here and I get the following error while encoding the string to UTF-8:
java.lang.RuntimeException: IOException reading reader invalid byte 11101001 Now - I didnt parse the file or done any changes to it - its just a plain text hebrew file. Should I have done any changes to it? The line "Edit the hebrew descriptions and saved in UTF-8 format. Assuming your text file contains value pairs delimited by an =.." makes no sense - but do you mean I need to change the file? Thanx ahead |
|
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|