You Are Here:

Community: Developer Discussion Boards

#1 Old Reading hebrew text file - 2003-12-24, 11:48

Join Date: Mar 2003
Posts: 8
nirmeidan
Offline
Registered User
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
Reply With Quote

#2 Old 2003-12-24, 17:37

Join Date: Mar 2003
Posts: 17
MARAMM
Offline
Registered User
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];
}
}
}
Reply With Quote

#3 Old 2003-12-25, 09:07

Join Date: Mar 2003
Posts: 8
nirmeidan
Offline
Registered User
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 :)
Reply With Quote

#4 Old Reading a hebrew text file - 2004-06-19, 21:17

Join Date: Feb 2004
Posts: 27
dd_plus
Offline
Registered User
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 With Quote

#5 Old Solution - 2004-06-20, 16:32

Join Date: Feb 2004
Posts: 27
dd_plus
Offline
Registered User
Ive written a detailed solution: http://discussion.forum.nokia.com/fo...threadid=45029

dd+
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia