microedition.encoding problem
Hello,
My Server transmits cyrillic strings to my midlet. On emulator everything is ok, because it seems it takes the default locale and encoding from the PC, but when I installed the midlet on my device, strings are not represented correctly. My phone supports Cyrillic.
Can someone help me - I found that I should modify the microedition.encoding property, but it seems not to help .... or may be I didn't modified it correctly.
Does anyone knows solution? I'm frustrated because my new project has to start on 1st Sep, and now I have such critical problem when I installed the software on real devices :(
Appreciate any help.
Peter
Hi ,
In fact the server sends sequence of bytes, which is read in the midlet with the socket read method. After, I just try to create String object with the received data, but it fails with unreadable characters when ran on real device .... but on emulator the characters are perfect, because my win encoding is Cp1251 and the emulator takes it by default.
I saw String class accepts also optional parameter for encoding, but I cannot find anywhere the supported encodings from MIDP. What I just tried that if you make String temp = new String( ...., ISO-8859-5), or
ISO8859-5, or Cp1251), it throws runtime exception when ran on real device. So, my hint now is to understand the exact names of the encoding supported from MIDP (which obviously differs from the standard encoding names), or to find how to set microedition.encoding with appropriate name.
For the microedition.encoding, I changed it in the property file but it didn't helped when installed on real device. In fact, after build, I didn't find this parameter in the manifest file, which makes me think it is used by WTK only for emulation, but is not bound in the jar file.
you did :String str = new String(bytesArray, "Cp1251");
?
did you try to use the setRequestProperty(String, String) with your HttpConnection onject like that:c.setRequestProperty("Content-Language", "Cp1251");
?
Message was edited by:
supareno
I use sockets, not HTTP connection object.
First, I read the data:
while (count >=0 && total < lenToReceive.intValue()) {
count = is.read(temp, total, lenToReceive.intValue() - total);
if (count <= 0) {
break;
}
total += count;
}
Then, I parse the byte array
paramName = new String(temp, offset, i-offset);
where paramName is String object. On emulator this works just fine and paramName contains readable characters.
I tried to do this:
paramName = new String(temp, offset, i-offset, "Cp1251"); but it throws runtime error due to Cp1251 parameter ...