JDK-6418187 : Invalid translations for arabic codepage 420
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-04-26
  • Updated: 2011-02-16
  • Resolved: 2006-04-27
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.4.2_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_09-b05)
Java HotSpot(TM) Client VM (build 1.4.2_09-b05, mixed mode)
1.4.2_11

ADDITIONAL OS VERSION INFORMATION :
Windows XP

A DESCRIPTION OF THE PROBLEM :
1- Method 1
- Load an arabic file in 420
- The string contain garbage

2- Method 2
-Create a string in unicode format
-Store the string in codepage 420 (cp420)
-the string stored is not all 420 (some characters are stored as 3F)

i downloaded the latest version 1.4.2_11 and the problem still persist. Please run the sample code i wrote in the save dialog and use a codepage 420 and using a hex editor you will find that some characters are saved as 0x3F

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
-Load a string in arabic unicode (FE range or 06 Range)
-Save the File in codepage (cp420)
-Load the file again in codepage(cp420)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
-The arabic string is readable
ACTUAL -
-The arabic string contain garbage letters and some are able to be reproduced correctly

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
//Loading module:
					try {
						FileDialog fileDlg = new FileDialog(mainGuiInstance, "Load", FileDialog.LOAD);
						fileDlg.show();
						String filePath = fileDlg.getDirectory() + fileDlg.getFile();
						Reader fr = new InputStreamReader(new FileInputStream(filePath),codepage);
						BufferedReader br = new BufferedReader(fr);
						String line = null;
						StringBuffer sb = new StringBuffer();
						while ((line = br.readLine())!=null ) {
							sb.append(line).append("\n");
						}
						fr.close();
						getTextInput().setText(sb.toString());
					} catch (Exception exp) {
						exp.printStackTrace();
					}
//Saving Module:
					try {
						FileDialog fileDlg = new FileDialog(mainGuiInstance, "Save", FileDialog.SAVE);
						fileDlg.show();
						String filePath = fileDlg.getDirectory() + fileDlg.getFile();
						Writer fw = new OutputStreamWriter(new FileOutputStream(filePath),codepage);
						String str = getTextOutput().getText();
						fw.write(str);
						fw.close();
					} catch (Exception exp) {
						exp.printStackTrace();
					}


//Codepage variable:
//codepage reproducing this bug is CP420
//Also try other values
//CP864
//CP1046
//CP1089

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
1) use the IBM JRE 1.4.1 which store with the correct codepage
2) use IBM Rational application developer

Comments
EVALUATION The latest Cp420 mappting table from cdctable (/home/sherman/TL/cs/cdctables/mappings) has way more entries than the mapping we used to build our Cp420 charset.
27-04-2006