Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Printing Strings containing '%' character produces incorrect output and may crash Series 40 SDK emulators (Known Issue)

From Wiki
Jump to: navigation, search

This known issue was originally created by Welco and has been verified by Nokia Developer.

Article Metadata
Tested with
Devices(s): Series 40 3rd Edition, FP1, Nokia 6212 NFC, Series 40 6th Edition SDK emulators
Created: welcor (02 May 2009)
Last edited: hamishwillee (01 Aug 2013)



System.out.println(String) and System.err.println(String) with String containing the '%' character produce incorrect output and may crash the emulator in Series 40 SDKs.


Calling System.out.println(String) and System.err.println(String) with Strings including the '%' character may crash the Series 40 SDK emulator.

In addition to the print methods, text Strings with %20 are not correctly written to the standard output.

The following test String is an example URL with escaped spaces:


For the affected Series 40 SDKs, the output from System.out.println and System.err.println is:

/Global/Charts/Metal/Copper/Fundamental OPPER 6292852g1.gif

For comparison, in S60 the result with the test SDKs (S60 5th Edition, v1.0 or the Nokia N97 SDK) is:


How to reproduce

1. Implement the following code snippet:

 import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class SimpleFormTest extends MIDlet {
Display d;
Form f;
public void startApp() {
f=new Form("New form");
System.err.println("Here%someline"); // This crashes the affected SDKs
// System.out.println("/Global/Charts/Metal/Copper/Fundamental%20COPPER%20Fig1.gif");
//The System.out above reproduces incorrect output result
public void pauseApp() {
public void destroyApp(boolean unconditional) {

2. Run the test MIDlet in the Series 40 SDK emulator. The emulator crashes in the affected SDKs. Run the test MIDlet in an S60 SDK emulator for comparison.

3. To test the incorrect output with '%20', replace the line System.err.println("Here%someline"); with System.err.println("/Global/Charts/Metal/Copper/Fundamental%20COPPER%20Fig1.gif"); by removing the comment marks.

4. Run the test MIDlet in the Series 40 SDK emulator. For the affected SDKs, the output result (for example, printed out in the output pane in Netbeans IDE) will be as described in the 'Description' regarding text Strings with %20. Run the test MIDlet in S60 SDK emulators for comparison.

In addition, steps 3 and 4 can be reproduced by using the following byte array:

byte[] test = {0x2F, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x2F, 0x43, 0x68, 
0x61, 0x72, 0x74, 0x73, 0x2F, 0x4D, 0x65, 0x74, 0x61, 0x6C, 0x2F, 0x43, 0x6F,
0x70, 0x70, 0x65, 0x72, 0x2F, 0x46, 0x75, 0x6E, 0x64, 0x61, 0x6D, 0x65, 0x6E,
0x74, 0x61, 0x6C, 0x25, 0x32, 0x30, 0x43, 0x4F, 0x50, 0x50, 0x45, 0x52, 0x25,
0x32, 0x30, 0x46, 0x69, 0x67, 0x31, 0x2E, 0x67, 0x69, 0x66};
System.out.println("no charset: "+new String(test));
System.out.println("ISO  : "+new String(test, "ISO-8859-1"));
System.out.println("UTF  : "+new String(test, "utf-8"));
} catch (UnsupportedEncodingException e)

Output for the affected SDKs:

no charset: /Global/Charts/Metal/Copper/Fundamental OPPER 6294100g1.gif
ISO       : /Global/Charts/Metal/Copper/Fundamental OPPER 6292852g1.gif
UTF       : /Global/Charts/Metal/Copper/Fundamental OPPER 6291304g1.gif

Output for S60 SDKs:

no charset: /Global/Charts/Metal/Copper/Fundamental%20COPPER%20Fig1.gif
ISO       : /Global/Charts/Metal/Copper/Fundamental%20COPPER%20Fig1.gif
UTF       : /Global/Charts/Metal/Copper/Fundamental%20COPPER%20Fig1.gif


For the affected SDKs, avoid using % and %20 in calls to System.out and System.err printing methods.

This page was last modified on 1 August 2013, at 06:04.
16 page views in the last 30 days.