Question

When i run my midlet with Java Wireless toolkit, midlet runs correctly, but when it try to parse a textfield, following error occurs;

java.lang.RuntimeException: IOException reading reader invalid first byte 10010111
    at com.sun.cldc.i18n.Helper.byteToCharArray(+228)
    at com.sun.cldc.i18n.Helper.byteToCharArray(+9)
    at java.lang.String.<init>(+7)
    at z.a(+219)
    at z.a(+103)
    at DP4JPhone.a(+74)
    at DP4JPhone.a(+115)
    at DP4JPhone.commandAction(+120)
    at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)
    at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
    at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
    at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
    at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.handleVmEvent(+186)
    at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+57)

What is the problem?

I am using JWT 2.5.2_01

Was it helpful?

Solution

Problem Solved.

As McDowell mentioned before, problem was about encoding settings. Best way to overcome this problem is declaring encoding info from WTK.

Within your working directory, find ktools.properties file ('workdir\wtklib\ktools.properties' or 'workdir\wtklib\Linux\ktools.properties' as is on my machine). And add the following lines:

microedition.encoding= *encoding*

For ASCII encoding:

microedition.encoding=ISO8859_1

That will do the job (:

OTHER TIPS

I would guess that it is because you are either:

  • using the String(byte[]) constructor (this constructor should generally be avoided)
  • using the String(byte[], String) constructor incorrectly

In both cases, you would be decoding byte data to character data using the wrong encoding, an encoding where the byte value 10010111 is illegal (at least, as a first byte).

Any conversion from byte data to char data (such as the creation of a String) will involve the transformation of data from "some other encoding" to UTF-16. You need to know and specify what that "some other encoding" is prior to performing this transformation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top