From 9911f5be93f7736fe1d3b271b408ca7ee6323218 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 24 Nov 1998 23:10:50 +0000 Subject: [PATCH] More complete quoted git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@135 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/decompiler/ClassAnalyzer.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/jode/jode/decompiler/ClassAnalyzer.java b/jode/jode/decompiler/ClassAnalyzer.java index dca7b1b..b4bdc43 100644 --- a/jode/jode/decompiler/ClassAnalyzer.java +++ b/jode/jode/decompiler/ClassAnalyzer.java @@ -174,13 +174,20 @@ public class ClassAnalyzer implements Analyzer { private static String quoted(String str) { StringBuffer result = new StringBuffer("\""); for (int i=0; i< str.length(); i++) { - switch (str.charAt(i)) { + char c; + switch (c = str.charAt(i)) { + case '\0': + result.append("\\0"); + break; case '\t': result.append("\\t"); break; case '\n': result.append("\\n"); break; + case '\r': + result.append("\\r"); + break; case '\\': result.append("\\\\"); break; @@ -188,7 +195,17 @@ public class ClassAnalyzer implements Analyzer { result.append("\\\""); break; default: - result.append(str.charAt(i)); + if (c < 32) { + String oct = Integer.toOctalString(c); + result.append("\\000".substring(0, 4-oct.length())) + .append(oct); + } else if (c >= 32 && c < 127) + result.append(str.charAt(i)); + else { + String hex = Integer.toHexString(c); + result.append("\\u0000".substring(0, 6-hex.length())) + .append(hex); + } } } return result.append("\"").toString();