You Are Here:

Community: Wiki

This page was last modified on 19 May 2009, at 11:52.

KIJ001384 - Printing Strings containing '%' character produces incorrect output and may crash Series 40 SDK emulators

From Forum Nokia Wiki


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


ID KIJ001384 Creation date May 19, 2009
Platform Series 40 3rd Edition, FP1, Nokia 6212 NFC, Series 40 6th Edition Devices Series 40 3rd Edition, FP1, Nokia 6212 NFC, Series 40 6th Edition SDK emulators
Category Java ME Subcategory SDK


Keywords (APIs, classes, methods, functions): System.out, System.err

Overview

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.

Description

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:

"/Global/Charts/Metal/Copper/Fundamental%20COPPER%20Fig1.gif"

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:

/Global/Charts/Metal/Copper/Fundamental%20COPPER%20Fig1.gif

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() {
       
       d=Display.getDisplay(this);
       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

       d.setCurrent(f);
       
   }

   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));
try
{
	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


Solution

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

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fKIS000313E5fE2dE5fCVideoPlayerUtilityE3aE3aSetE52otationE4cE28E29E5fcrashE5forE5ferroneousE5fbehaviorX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZKnowledgeBaseContentQ qdcZtypeQUqfntypeZKnownIssueQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZKnowledgeBaseContentQ qfnZtypeQUqfntypeZKnownIssueQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZKnowledgeBaseContentQ qrdfZtypeQUqfntypeZKnownIssueQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ