Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j/encoding
In directory sc8-pr-cvs1:/tmp/cvs-serv4879/src/org/tn5250j/encoding
Modified Files:
CharMappings.java NativeCodePage.java ToolboxCodePage.java
Log Message:
added check if a java codepage/encoding is available
Index: CharMappings.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/encoding/CharMappings.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CharMappings.java 9 Jul 2003 18:55:40 -0000 1.2
--- CharMappings.java 21 Jan 2004 13:11:14 -0000 1.3
***************
*** 56,60 ****
map.put(encoding, cp);
return cp;
! }
cp = ToolboxCodePage.getCodePage(encoding);
--- 56,60 ----
map.put(encoding, cp);
return cp;
! }
cp = ToolboxCodePage.getCodePage(encoding);
***************
*** 74,77 ****
--- 74,78 ----
// unsupported codepage
// ==> return default;
+ System.err.println("CodePage" + encoding + " not supported, using default (" + DFT_ENC + ")");
return NativeCodePage.getCodePage(DFT_ENC);
}
Index: NativeCodePage.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/encoding/NativeCodePage.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** NativeCodePage.java 17 Jun 2003 06:09:08 -0000 1.4
--- NativeCodePage.java 21 Jan 2004 13:11:14 -0000 1.5
***************
*** 128,132 ****
} catch (java.io.UnsupportedEncodingException uee) {
! uee.printStackTrace();
}
return b;
--- 128,132 ----
} 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;
--- 138,142 ----
b = characterToString(index).getBytes("Cp1140")[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;
--- 148,152 ----
b = characterToString(index).getBytes("Cp1147")[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;
--- 158,162 ----
b = characterToString(index).getBytes("Cp1112")[0];
} catch (java.io.UnsupportedEncodingException uee) {
! System.err.println(uee);
}
return b;
***************
*** 1204,1207 ****
--- 1204,1208 ----
static final CodePage getCodePage(String cp)
{
+ System.err.println("Trying NativeCodePage:" + cp);
if (cp.equals("37"))
return new NativeCodePage(cp, codePage37);
***************
*** 1240,1247 ****
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);
--- 1241,1260 ----
if (cp.equals("1026"))
return new NativeCodePage(cp, codePage1026);
! if (cp.equals("1141")) {
! if (isEncodingAvailable("1141")) {
! return new NativeCodePage(cp, codePage1141);
! } else {
! System.err.println("Charset encoding 1141 not available");
! return null;
! }
! }
! if (cp.equals("1140")) {
! if (isEncodingAvailable("1140")) {
! 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);
***************
*** 1268,1270 ****
}
! }
\ No newline at end of file
--- 1281,1300 ----
}
! /**
! * 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;
! }
! }
Index: ToolboxCodePage.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/encoding/ToolboxCodePage.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ToolboxCodePage.java 9 Jul 2003 18:55:40 -0000 1.2
--- ToolboxCodePage.java 21 Jan 2004 13:11:14 -0000 1.3
***************
*** 76,79 ****
--- 76,81 ----
public static CodePage getCodePage(String encoding)
{
+ System.err.println("Trying ToolboxCodePage:" + encoding);
+
if (CONVERTER_CONSTRUCTOR == null)
return null;
***************
*** 86,89 ****
--- 88,92 ----
catch (Throwable t)
{
+ System.err.println("Error while loading " + CONVERTER_NAME + ": " + t);
conv = null;
}
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.