tn5250j/src/org/tn5250j/encoding CharMappings.java,1.3,1.4 NativeCodePage.java,1.7,1.8 ToolboxCodePage.java,1.4,1.5
Patrick Bielen <[email protected]> Wed, 31 Mar 2004 12:25:10 +0000
| Newsgroups | gmane.comp.java.tn5250j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j/encoding
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23849/src/org/tn5250j/encoding
Modified Files:
CharMappings.java NativeCodePage.java ToolboxCodePage.java
Log Message:
Submitted by: Kenneth
Various updates to update CVS with actual code
Index: CharMappings.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/encoding/CharMappings.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CharMappings.java 21 Jan 2004 13:11:14 -0000 1.3
--- CharMappings.java 31 Mar 2004 12:25:08 -0000 1.4
***************
*** 74,81 ****
// unsupported codepage
// ==> return default;
- System.err.println("CodePage" + encoding + " not supported, using default (" + DFT_ENC + ")");
return NativeCodePage.getCodePage(DFT_ENC);
}
private static final HashMap map = new HashMap();
! }
\ No newline at end of file
--- 74,80 ----
// unsupported codepage
// ==> return default;
return NativeCodePage.getCodePage(DFT_ENC);
}
private static final HashMap map = new HashMap();
! }
Index: NativeCodePage.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/encoding/NativeCodePage.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** NativeCodePage.java 23 Mar 2004 14:06:22 -0000 1.7
--- NativeCodePage.java 31 Mar 2004 12:25:08 -0000 1.8
***************
*** 93,108 ****
}
- if (encoding.equals("1148")) {
- char c = ' ';
- try {
- byte[] b = new byte[1];
- b[0] = (byte)index;
- c = (new String(b, "Cp1148")).charAt(0);
- } catch (java.io.UnsupportedEncodingException uee) {
- uee.printStackTrace();
- }
- return c;
- }
-
if (encoding.equals("1112")) {
char c = ' ';
--- 93,96 ----
***************
*** 140,144 ****
} catch (java.io.UnsupportedEncodingException uee) {
! System.err.println(uee);
}
return b;
--- 128,132 ----
} catch (java.io.UnsupportedEncodingException uee) {
! uee.printStackTrace();
}
return b;
***************
*** 150,154 ****
b = characterToString(index).getBytes("Cp1140")[0];
} catch (java.io.UnsupportedEncodingException uee) {
! System.err.println(uee);
}
return b;
--- 138,142 ----
b = characterToString(index).getBytes("Cp1140")[0];
} catch (java.io.UnsupportedEncodingException uee) {
! uee.printStackTrace();
}
return b;
***************
*** 160,174 ****
b = characterToString(index).getBytes("Cp1147")[0];
} catch (java.io.UnsupportedEncodingException uee) {
! System.err.println(uee);
! }
! return b;
! }
!
! if (encoding.equals("1148")) {
! byte b = 0x0;
! try {
! b = characterToString(index).getBytes("Cp1148")[0];
! } catch (java.io.UnsupportedEncodingException uee) {
! System.err.println(uee);
}
return b;
--- 148,152 ----
b = characterToString(index).getBytes("Cp1147")[0];
} catch (java.io.UnsupportedEncodingException uee) {
! uee.printStackTrace();
}
return b;
***************
*** 180,184 ****
b = characterToString(index).getBytes("Cp1112")[0];
} catch (java.io.UnsupportedEncodingException uee) {
! System.err.println(uee);
}
return b;
--- 158,162 ----
b = characterToString(index).getBytes("Cp1112")[0];
} catch (java.io.UnsupportedEncodingException uee) {
! uee.printStackTrace();
}
return b;
***************
*** 269,274 ****
} else if(encoding.toLowerCase().startsWith("1147")) {
convert = true;
- } else if(encoding.toLowerCase().startsWith("1148")) {
- convert = true;
} else if(encoding.toLowerCase().startsWith("1112")) {
convert = true;
--- 247,250 ----
***************
*** 428,432 ****
"277-dk","277-no","278","297","424","500-ch",
"870-pl","870-sk","871","875","1025-r","1026",
! "1112","1141","1140","1147", "1148"};
/* Conversion table generated mechanically by Free `recode' 3.5
--- 404,408 ----
"277-dk","277-no","278","297","424","500-ch",
"870-pl","870-sk","871","875","1025-r","1026",
! "1112","1141","1140","1147"};
/* Conversion table generated mechanically by Free `recode' 3.5
***************
*** 1189,1231 ****
};
- /* Code page 1148 copied from 500ch */
-
- private static final int[] codePage1148 = {
-
- 0, 1, 2, 3, 156, 9, 134, 127, /* 0 - 7 */
- 151, 141, 142, 11, 12, 13, 14, 15, /* 8 - 15 */
- 16, 17, 18, 19, 157, 133, 8, 135, /* 16 - 23 */
- 24, 25, 146, 143, 28, 29, 30, 31, /* 24 - 31 */
- 128, 129, 130, 131, 132, 10, 23, 27, /* 32 - 39 */
- 136, 137, 138, 139, 140, 5, 6, 7, /* 40 - 47 */
- 144, 145, 22, 147, 148, 149, 150, 4, /* 48 - 55 */
- 152, 153, 154, 155, 20, 21, 158, 26, /* 56 - 63 */
- 32, 160, 226, 228, 224, 225, 227, 229, /* 64 - 71 */
- 231, 241, 91, 46, 60, 40, 43, 33, /* 72 - 79 */
- 38, 233, 234, 235, 232, 237, 238, 239, /* 80 - 87 */
- 236, 223, 93, 36, 42, 41, 59, 94, /* 88 - 95 */
- 45, 47, 194, 196, 192, 193, 195, 197, /* 96 - 103 */
- 199, 209, 166, 44, 37, 95, 62, 63, /* 104 - 111 */
- 248, 201, 202, 203, 200, 205, 206, 207, /* 112 - 119 */
- 204, 96, 58, 35, 64, 39, 61, 34, /* 120 - 127 */
- 216, 97, 98, 99, 100, 101, 102, 103, /* 128 - 135 */
- 104, 105, 171, 187, 240, 253, 254, 177, /* 136 - 143 */
- 176, 106, 107, 108, 109, 110, 111, 112, /* 144 - 151 */
- 113, 114, 170, 186, 230, 184, 198, 164, /* 152 - 159 */
- 181, 126, 115, 116, 117, 118, 119, 120, /* 160 - 167 */
- 121, 122, 161, 191, 208, 221, 222, 174, /* 168 - 175 */
- 162, 163, 165, 183, 169, 167, 182, 188, /* 176 - 183 */
- 189, 190, 172, 124, 175, 168, 180, 215, /* 184 - 191 */
- 123, 65, 66, 67, 68, 69, 70, 71, /* 192 - 199 */
- 72, 73, 173, 244, 246, 242, 243, 245, /* 200 - 207 */
- 125, 74, 75, 76, 77, 78, 79, 80, /* 208 - 215 */
- 81, 82, 185, 251, 252, 249, 250, 255, /* 216 - 223 */
- 92, 247, 83, 84, 85, 86, 87, 88, /* 224 - 231 */
- 89, 90, 178, 212, 214, 210, 211, 213, /* 232 - 239 */
- 48, 49, 50, 51, 52, 53, 54, 55, /* 240 - 247 */
- 56, 57, 179, 219, 220, 217, 218, 159, /* 248 - 255 */
- };
-
-
/* Conversion table generated mechanically by Free `recode' 3.5
for sequence IBM278..ISO-8859-1 (reversible). */
--- 1165,1168 ----
***************
*** 1267,1271 ****
static final CodePage getCodePage(String cp)
{
- System.err.println("Trying NativeCodePage:" + cp);
if (cp.equals("37"))
return new NativeCodePage(cp, codePage37);
--- 1204,1207 ----
***************
*** 1304,1329 ****
if (cp.equals("1026"))
return new NativeCodePage(cp, codePage1026);
! if (cp.equals("1141")) {
! if (isEncodingAvailable("Cp1141")) {
! return new NativeCodePage(cp, codePage1141);
! } else {
! System.err.println("Charset encoding 1141 not available");
! return null;
! }
! }
! if (cp.equals("1140")) {
! if (isEncodingAvailable("Cp1140")) {
! return new NativeCodePage(cp, codePage1140);
! } else {
! System.err.println("Charset encoding 1140 not available");
! return null;
! }
! }
if (cp.equals("1147"))
return new NativeCodePage(cp, codePage1147);
- if (cp.equals("1148"))
- return new NativeCodePage(cp, codePage1148);
-
// return codePage37;
return null;
--- 1240,1250 ----
if (cp.equals("1026"))
return new NativeCodePage(cp, codePage1026);
! if (cp.equals("1141"))
! return new NativeCodePage(cp, codePage1141);
! if (cp.equals("1140"))
! return new NativeCodePage(cp, codePage1140);
if (cp.equals("1147"))
return new NativeCodePage(cp, codePage1147);
// return codePage37;
return null;
***************
*** 1347,1366 ****
}
! /**
! * Checks if a charset-encoding is available
! *
! * @param encoding Codepage
! * @return true if the encopding is available
! *
! */
! public static boolean isEncodingAvailable(String encoding) {
! // I hope there's more elegant way to do this
! // JDK1.4 only: java.nio.charset.Charset.
! try {
! byte b = "dummy".getBytes(encoding)[0];
! } catch (java.io.UnsupportedEncodingException uee) {
! return false;
! }
! return true;
! }
! }
--- 1268,1270 ----
}
! }
\ No newline at end of file
Index: ToolboxCodePage.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/encoding/ToolboxCodePage.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ToolboxCodePage.java 27 Jan 2004 17:03:12 -0000 1.4
--- ToolboxCodePage.java 31 Mar 2004 12:25:08 -0000 1.5
***************
*** 76,82 ****
public static CodePage getCodePage(String encoding)
{
- String codePageName = "Cp" + encoding;
- System.err.println("Trying ToolboxCodePage:" + codePageName);
-
if (CONVERTER_CONSTRUCTOR == null)
return null;
--- 76,79 ----
***************
*** 85,99 ****
try
{
! conv = CONVERTER_CONSTRUCTOR.newInstance(new Object[] {codePageName});
}
catch (Throwable t)
{
- System.err.println("Error while loading " + CONVERTER_NAME + ": " + t);
- t.printStackTrace();
conv = null;
}
if (conv != null)
! return new ToolboxCodePage(codePageName, conv);
return null;
--- 82,94 ----
try
{
! conv = CONVERTER_CONSTRUCTOR.newInstance(new Object[] {encoding});
}
catch (Throwable t)
{
conv = null;
}
if (conv != null)
! return new ToolboxCodePage(encoding, conv);
return null;
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click