Skip to Main Content
IBM Power Ideas Portal


This portal is to open public enhancement requests against IBM Power Systems products, including IBM i. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Delivered
Workspace IBM i
Categories JAVA
Created by Guest
Created on Jul 11, 2016

Java File class getCanonicalFile does not support all Unicode characters

The Java File class methods getCanonicalFile and getCanonicalPath call a native ILE function that is dependent on the current job CCSID.
This limits the range of Unicode characters that can be supported.
Java is a Unicode language and the IFS file system supports Unicode path names.
The canonicalize method needs to deal with the IFS file path using Unicode characters and not convert the path to a single byte or double byte CCSID characters.

Refer to PMR 29430,756


Use Case:

Scenario: The current folder contains files which have Japanese and Greek characters.

File folder = new File ( "." ) ;

File[] fileArray = folder.listFiles () ;

File file = fileArray[0].

The file.getName() method will contain Japanese and Greek Unicode characters.

File file = fileArray[i].getCanonicalFile () ;

The file.getName() method will contain some Unicode Substitute/Replacement characters as the native CCSID conversion has lost some characters during code page conversion.

============================================

import java.io.* ;

import java.util.Map ;
import java.util.Enumeration ;

public class Test
{
private final static char[] MAP = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' } ;

public static void main ( String[] args ) throws Exception
{
traceEnv () ;

traceSystemProperties () ;

traceFiles () ;
}

private final static void traceFiles () throws IOException
{
File folder = new File ( "." ) ;

File[] fileArray = folder.listFiles () ;

FileOutputStream outputStream = new FileOutputStream ( "OUTPUT.TXT" ) ;

for ( int i=0; i < fileArray.length; i++ )
{
/*
File from folder
*/

if ( fileArray[i].getName ().endsWith ( ".png" ) )
{
traceFile ( outputStream, fileArray[i] ) ;

traceFile ( outputStream, fileArray[i].getCanonicalFile () ) ;
}
}

outputStream.close () ;
}

private final static void traceFile ( FileOutputStream outputStream, File file ) throws IOException
{
try
{
String name = file.getName () ;

write ( outputStream, "" ) ;
write ( outputStream, "[" + name + "] [" + encode ( name.toCharArray () ) + "]" ) ;
write ( outputStream, " exists " + file.exists () ) ;
write ( outputStream, " length " + file.length () ) ;

byte[] content = readFile ( file ) ;

write ( outputStream, " bytes " + content.length ) ;
}
catch ( Exception e )
{
write ( outputStream, " bytes " + e.getMessage () ) ;
}
}

private final static void traceEnv () throws IOException
{
FileOutputStream outputStream = new FileOutputStream ( "ENV.TXT" ) ;

Map<String,String> map = System.getenv () ;

for ( String name : map.keySet () )
{
String value = System.getenv ( name ) ;

write ( outputStream, "[" + name + "] [" + value + "]" ) ;
}

outputStream.close () ;
}

private final static void traceSystemProperties () throws IOException
{
FileOutputStream outputStream = new FileOutputStream ( "SYSTEM.TXT" ) ;

Enumeration enumeration = System.getProperties().propertyNames () ;

while ( enumeration.hasMoreElements () )
{
String name = (String)enumeration.nextElement () ;

String value = System.getProperty ( name ) ;

write ( outputStream, "[" + name + "] [" + value + "]" ) ;
}

outputStream.close () ;
}

private final static void write ( OutputStream outputStream, String line ) throws IOException
{
outputStream.write ( line.getBytes ( "UTF-8" ) ) ;

outputStream.write ( "\r\n".getBytes ( "UTF-8" ) ) ;
}

private final static String encode ( char[] c )
{
StringBuffer buffer = new StringBuffer ( 64 ) ;

for ( int i=0; i < c.length; i++ )
{
buffer.append ( encode ( c[i] ) ) ;
}

return new String ( buffer ) ;
}

private final static String encode ( char c )
{
int index1 = (c & 0xF000) >>> 12 ;
int index2 = (c & 0x0F00) >>> 8 ;
int index3 = (c & 0x00F0) >>> 4 ;
int index4 = (c & 0x000F) ;

return "\\u" + MAP [ index1 ] + MAP [ index2 ] + MAP [ index3 ] + MAP [ index4 ] ;
}

private final static byte[] readFile ( File file ) throws IOException
{
int length = (int)file.length () ;

byte[] content = new byte[length] ;

FileInputStream inputStream = new FileInputStream ( file ) ;

inputStream.read ( content ) ;

inputStream.close () ;

return content ;
}
}


Idea priority Low
  • Guest
    Reply
    |
    Jun 22, 2017

    jdk7, jdk7.1, jdk80 on i 7.2 and above releases will include the enhancement.

    For IBM i 7.3, it is included in PTF group SF99725 level 4 (released). We will update with PTF information for IBM i 7.2 at a future time.

  • Guest
    Reply
    |
    Jul 13, 2016

    Creating a new RFE based on Community RFE #91328 in product IBM i.