Update of /cvsroot/jake2/jake2/src/jake2/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23988/src/jake2/util
Modified Files:
Lib.java
Log Message:
convert a java string to byte[] with 8bit latin 1.
avoid String.getBytes() because it is using system specific character encoding.
Network messages can fail, see rcon on a linux system.
Index: Lib.java
===================================================================
RCS file: /cvsroot/jake2/jake2/src/jake2/util/Lib.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** Lib.java 16 Dec 2005 21:19:42 -0000 1.16
--- Lib.java 18 Dec 2005 16:34:13 -0000 1.17
***************
*** 302,305 ****
--- 302,319 ----
return out;
}
+
+ /**
+ * convert a java string to byte[] with 8bit latin 1
+ *
+ * avoid String.getBytes() because it is using system specific character encoding.
+ */
+ public static byte[] stringToBytes(String value) {
+ try {
+ return value.getBytes("ISO-8859-1");
+ } catch (UnsupportedEncodingException e) {
+ // can't happen: Latin 1 is a standard encoding
+ return null;
+ }
+ }
/** Helper method that savely handles the null termination of old C String data. */
|