Gemalto is now part of the Thales Group, find out more.

You are here

character encoding on EHSx | Thales IoT Developer Community

barkmann

September 5, 2018 - 11:45am, 777 views

Dear,

I have 2 different projects where I need to read a String from a text(txt) file on the module. One is with the TC65i and one with the EHS8.

When reading with the EHS8 I can’t read ‘characters like ä, ü and ö. With the TC65i I don’t have this issue when using the exact same code.

In the example below I have a text file (file:///A:/textfile.txt)  with the 3 characters above in it. When I read and output them or send them by SMS I only get question marks.

Am I missing something?

Regards

public static void read_file(){

        try {

              FileConnection fconn = (FileConnection)Connector.open("file:///A:/textfile.txt", Connector.READ_WRITE);

              if (!fconn.exists())

              {                 

System.out.println("file not found");               

              }

              else

              {

                    InputStreamReader fdi = new InputStreamReader(fconn.openInputStream(), "ISO_8859_1");

                    int ch;                   

               

                    while ( (ch = fdi.read()) != -1) {

System.out.println((char)ch);

                    }

 

                    fdi.close();

                    fconn.close();

              }                                    

         }

         catch (Exception ex)

         {

System.out.println("Exception found: " + ex.toString() + "\r");

         }

}