summaryrefslogtreecommitdiffstats
path: root/src/jake2/util/Lib.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jake2/util/Lib.java')
-rw-r--r--src/jake2/util/Lib.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/jake2/util/Lib.java b/src/jake2/util/Lib.java
index c65e17f..269f039 100644
--- a/src/jake2/util/Lib.java
+++ b/src/jake2/util/Lib.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 09.12.2003 by RST.
-// $Id: Lib.java,v 1.17 2005-12-18 16:34:13 cawe Exp $
+// $Id: Lib.java,v 1.18 2005-12-18 22:10:12 cawe Exp $
package jake2.util;
@@ -208,12 +208,12 @@ public class Lib {
return;
int diff = len - s.length();
if (diff > 0) {
- f.write(s.getBytes());
+ f.write(stringToBytes(s));
f.write(nullfiller, 0, diff);
}
else
- f.write(s.getBytes(), 0, len);
+ f.write(stringToBytes(s), 0, len);
}
/** Like in libc */
@@ -315,6 +315,20 @@ public class Lib {
return null;
}
}
+
+ /**
+ * convert a byte[] with 8bit latin 1 to java string
+ *
+ * avoid new String(bytes) because it is using system specific character encoding.
+ */
+ public static String bytesToString(byte[] value) {
+ try {
+ return new String(value, "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. */
public static String CtoJava(String old) {