×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Jan 2010
    Posts
    52

    Reading Unicode File from a Resource

    Hey guys,

    I'm using J2ME to develop a MIDlet on a Nokia S40 device.
    I'm also using kXml to read an xml file from a resource file.
    When the xml file is in english, there is no problem. But when I try to read non english characters from the file, I get weird character on the screen.

    Lets say I have a StringItem called 'item'.

    item.setText("non-english-text"); // - works and display the text perfectly on the device.
    item.setText(readXml()); // - shows weird characters on the screen (probably doesn't handle the UTF-8 because it shows an 'x' after every character which probably stands for \n. The text looks somewhat like this "£xåx█x█x▐x")

    this is the code that reads the xml file:
    m_parser = new XmlParser(new InputStreamReader(this.getClass().getResourceAsStream(file_name)));

    any ideas?

    Thanks!

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    Did you have a look at the Javadoc about InputStreamReader? Is there a reason not use use kXML2? With that, you do not have to create a Reader and specify an encoding at all because it does auto-detection from the InputStream.
    Last edited by traud; 2010-05-26 at 12:01.

Similar Threads

  1. MBM image is not found
    By tamhanna in forum Symbian
    Replies: 14
    Last Post: 2009-04-20, 12:44
  2. [split] mbm build error
    By mando222 in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2009-03-29, 12:32
  3. Replies: 13
    Last Post: 2007-12-07, 11:21
  4. Resource file
    By hicheri in forum Symbian
    Replies: 2
    Last Post: 2005-02-24, 20:25
  5. Problems with CBA resource in 2nd Resource File.
    By colinlawrence in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2004-02-17, 02:47

Posting Permissions

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