×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    8

    Reading hebrew text file

    hey

    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

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    17
    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];
    }
    }
    }

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    8
    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

  4. #4
    Registered User
    Join Date
    Feb 2004
    Posts
    29

    Reading a hebrew text file

    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

  5. #5
    Registered User
    Join Date
    Feb 2004
    Posts
    29

    Solution

    Ive written a detailed solution: http://discussion.forum.nokia.com/fo...threadid=45029

    dd+

Posting Permissions

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