character encoding on EHSx | Telit Cinterion IoT Developer Community
September 5, 2018 - 11:45am, 2550 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");
}
}
Hi
I've done some test on EHS8. I've created a file in encoding format UTF-8 and ISO_8859_1 and in Java midlet i use this encondig and both works the same.
The value is the same as in UTF-8 table. For exaple for ö I've got 246 value in hexadecimal it is 0xF6. Unfortunatelly when I've sended SMS I've got empty values. My SMS was: "ä, ü and ö" and in my phone showed " , and ". So I think in Java Midlet the module read and show correct values because it agrees with the UTF-8 table.
In next week I should have TC65i and environment for this so I will could try to check it's behaviur if you want to.
Regards
Krzysztof
I dissagree on this. When reading from a text file with the TC65i it works ok.
When creating a Java project that reads a file from the hard-drive and output the charachter's it also works ok and shows the correct characters:
Also when I create a string like String x = "äüö"; and ley the EHSx send this by SMS it's no problem, I receive the correct characters on my phone.
So we can hardly state the EHSx is doing it right when converting int values into the propper characters.
Hi
I've checked it again. I have your first Java code and then I've created Java midlet to read data from file and then send it by SMS. I have created a TXT file witch äüö characters. I saved it as ISO_8859_1 encoding type. Then I opened YAAT terminal and there i can see my all file. I also added to show an integer values and this is agrees with UTF-8 / ISO_8859_1 table. I've checked it by also using "UTF-8" encoding in Java and by created in that encoded format txt file and it works again.
Using terminal like ZOC or Putty shows only blank characters. In ZOC i can display it as HEX values and then it works properly. When I use YAAT terminal there i can see normally äüö.
First I've sendet normally SMS and I had blank characters. Then i added a Java method: ATStringConverter.Java2GSM(messageToSendSMS) which returns a String and afterwards it's looks okay. I read all good message from hard-drive memory on my mobile phone.
Can you write what is rour revision of module (ATI1 command)?
So if i good understand you, that you have problem with sending SMS from readed data form memory? Could you inform me if you are using Java2GSM method?
Please write more specific information beceause in that way i can't reproduce your isse.
Regards
Krzysztof
Krzysztof,
I used a modem with old firmware and updated it to ARN51. Problem is solved now. Thanks for the replies.
regards